I have written a small program t开发者_如何学Co validate 3 data files and convert them into a csv file.
-Every file is converted by a different class file
-There is a main class which instantiates all the other classes for processing files one after other
How do i make sure that the next file is processed only after the previous file is done?
The pseudocode for my program is as follows
mainExecute Class()
{
executeFile1converter();
executeFile2Converter();
executeFile3Converter();
}
If its single threaded and there is no exception/error occurred then it guarantees that behavior
Code execution is linear if you don't introduce concurrency yourself. So just calling the things one after the other is enough.
Unless of course you're calling into libraries that process data asynchronously, but then they should have APIs that let you know when they're done.
They will execute in the specified order by definition. One row must finish executing before the next row starts. You seem to be talking about simultaneous execution, but you need additional explicit definitions to accompish that - i.e. executeFile1converter
spawns a thread. Then you'll need an event fired when it completes.
As long as the different class files don't start threads to do the work, you needn't bothter. Sequential work is the default.
If the executeFileXConverter() methods create a new processes, retrieving the return code for the subprocess is sufficient for making sure it completes before proceeding since the return code isn't available until the subprocess exits returning it.
精彩评论