views:

315

answers:

1

I have a Java application that launches an external process (Internet Explorer) using ProcessBuilder. Strangely enough, this child process freezes when the parent Java thread calls Thread.sleep. It does not happen with all processes, for instance Firefox, but with IE it happens all the time.

Any ideas ?

P.S. I tried Robot.delay() with the same effect

+5  A: 

How are you consuming the child process stdout and stderr ? It may be worth posting your code.

You need to consume the output streams concurrently, otherwise either your stdout or stderr buffer will fill up, and your child process will block. See here for more details.

Brian Agnew
I'm not. I did not know I have to as IE does not use stdin/stdout, but I will try your suggestion anyway.
Demiurg
Definitely try it. I got hit by a similar thing years ago with an app I also assumed didn't do anything with stdin/stdout; you still had to use StreamGobbler or like means to make it work.
M1EK