Reputation: 392
Is there a difference between java.lang.Process.waitFor() and exitValue()?
Upvotes: 2
Views: 2147
Reputation: 8841
exitValue
throws an IllegalThreadStateException
if the subprocess is not terminated and returns the exit value if its terminated.
WaitFor
will block the calling thread until the subprocess is terminated and returns immediately if it has already been terminated.
So i would say that they will both behave the same when the subprocess is already terminated but will behave differently when it is still running.
If the subprocess is running , exitValue
will throw an excpetion and waitFor
will block the calling thread.
Upvotes: 5