Last Few Days I am facing a small problem. Its related to threads. I am creating a thread, in its run() method i am calling a batch file by using the following command,
Process p = Runtime.getRuntime().exec("MySample1.bat");
Now, the problem is, i want to run few more batches(say MySample2.bat, MySample3.bat..) in loop. Before that i want to make sure that the batches run one afer another....
Any kind of suggessions are welcome...
Best Regards,
Rushikesh Wagh
SCJP 1.4 (2005)
SCJP 1.6 (2010)
Hi, You can use this command p.waitFor(); "causes the current thread to wait, if necessary, until the process represented by this Process object has terminated. This method returns immediately if the subprocess has already terminated. If the subprocess has not yet terminated, the calling thread will be blocked until the subprocess exits."
Put this at the start (or end) of the for loop to make it wait for the batch process to finish before kicking off the next one.