java.lang.Process.waitFor()

Erik Poupaert erik.poupaert@freestyler-toolkit.org
Sun Sep 28 15:23:00 GMT 2003


> I prettied this up once, but can't find the code anymore. I think I might have also
> added a Thread.join(), but can't remember.

Thanks Mohan.
"Thread.join()" seems indeed the way to wait for another thread to finish. I think
it's perfect now; and it works perfectly on linux. I've removed the silly
"Thread.sleep()" and replaced it:
		threadIn.start();
		threadOut.start();
		threadErr.start();
		//wait until process truly exits before looking at its exit value	
		mExitCode=process.waitFor();
		//wait until process all child streams have been processed	
		threadIn.join(0);
		threadOut.join(0);
		threadErr.join(0);
		//recover output now
		mProcOutput=threadOut.getOutput();
		mProcErr=threadErr.getOutput();
I just hope that it works on GCJ 3.3/win32 as well?
Erik


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /