This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: java.lang.Process.waitFor()
> Why not simply wait on an object with "synchronized"?
I thought in direction too, but I don't know if I can apply it. I'm starting three
threads. One feeds input to stdin; the two others capture output from stdout and
stderr. I shouldn't interfere or block anything until the child process has exited;
the threads should run inimpeded until then. Would you know how to introduce an
object here?
Process process=Runtime.getRuntime().exec(execArgs);
ProcessOutputStreamThread threadIn=
new ProcessOutputStreamThread(
process.getOutputStream(),pInputStream);
ProcessInputStreamThread threadOut=
new ProcessInputStreamThread(process.getInputStream());
ProcessInputStreamThread threadErr=
new ProcessInputStreamThread(process.getErrorStream());
threadIn.start();
threadOut.start();
threadErr.start();
mExitCode=process.waitFor();
while (!threadOut.finished())
{
Thread.sleep(25);
}
while (!threadErr.finished())
{
Thread.sleep(25);
}
mProcOutput=threadOut.getOutput(); //String
mProcErr=threadErr.getOutput(); //String