2

I am using the Runtime.getRunTime() method to call an exe for web service in Java. If I call this without using Process.wait() then it works fine but if I use this with the wait() method then my process hangs and I have to restart Tomcat.

Can any one tell why this happens?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
matti
  • 21
  • 1
  • 1
    A code snippet showing what you have, what's working, and what's not, would help. – M K Oct 20 '12 at 07:36

1 Answers1

0

This shows you WHY the program "waitsFor()" the external process to finish executing.

Now, there is a possibility that the external program is requesting stdout and stderr, which your program is blocking. This is causing a perpetual wait or what's called the deadlock. See this for more details.

Community
  • 1
  • 1
Aniket Inge
  • 25,375
  • 5
  • 50
  • 78
  • If I use waitFor() then process waits indefinite time and I have to restart tomcat server .My code snippet for this is: Process p=Runtime.getRuntime().exec("--path of exe which I taken from cmd line parameter") p.waitFor() – matti Oct 20 '12 at 16:25
  • @matti that's probably because your program is going into a deadlock. One is waiting for the other process to exit, while the other process is waiting to gain "stdout"/"stderr" access. – Aniket Inge Oct 20 '12 at 18:10