java.lang.Process.waitFor()

Andrew Haley aph@redhat.com
Sun Sep 28 12:16:00 GMT 2003


Erik Poupaert writes:
 > 
 > When forking a subprocess in gcj, java.lang.Process.waitFor() may
 > return, before I've finished reading Process.getInputStream() or
 > Process.getErrorStream().
 > 
 > Does anybody know what the appropriate way is to wait for the
 > inputstream-reading thread to complete? What I do now, is to create
 > a method "finished()" that will only return true when the
 > Process.getInputStream() is empty:
 > 
 > 		while (!threadOut.finished()) 
 > 		{
 > 			Thread.sleep(50);
 > 		}
 > 
 > Is there a better way to do this? I mean with all the
 > monitor/threading infrastructure available in gcj, the snippet
 > above probably looks rather primitive.
Why not simply wait on an object with "synchronized"?
Andrew.


More information about the Java mailing list

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