This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
java.lang.Process.waitFor()
Andrew Haley writes:
> 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"?
Finger error. I mean "wait". :-)
Andrew.