I never noticed this before, but when I run an external program through
Runtime, like this:
Runtime rt = Runtime.getRuntime();
System.out.println("Running external command: " + sCommand);
try {Process p = rt.exec(sCommand);} catch (Exception e)
{System.out.println("Cannot Run Command: " + sCommand + ", Error: " + e);}
the external command is asynchronous -- completely spun off as a separate
thread or process. Is there any way to avoid this? I have an external
command that creates a number of files. Once they're created by the other
program, I want to use them in my system. Is there a way to wait on a
Runtime object until the program finishes running? Or a way to check on it
and see if it is completed?
I figure I could also add in a loop to wait until the Runtime commands
create certain files (or alter others), but I can forsee more complications
with that than with some way to wait until the command is done.
I searched the Java SDK docs, but can't find methods in Runtime that will
help.
Thanks for any help.
Hal