exec – IllegalThreadStateException: process has not exited

This is one nasty exception I experienced today.

I execute one .executable file from java. Reading the inputstream and the error stream with two different threads (why). I wait till ‘join’ing the thread then I took the process exit value.

processLogThread.join();
errorLogThread.join();
 try {
 logger.info("Thread status:"+processLogThread.isAlive()+" "+errorLogThread.isAlive());
 logger.info("Process exit value:"+p.exitValue());
 } catch (Exception e) {
 logger.error("Error while reading process exit value", e);
 }

Unfortunately, it threw the following exception. The streams are closed. Threads are dead. But it says process has not exited. aaw!!

18:19:39,802         INFO Utilities:432 - Thread status:false false
18:19:39,805        ERROR Utilities:435 - Error while reading process exit value
java.lang.IllegalThreadStateException: process has not exited
 at java.lang.ProcessImpl.exitValue(Native Method)
 at com.eginnovations.license.util.Utilities.genLicense5(Utilities.java:433)

Comments are closed.