Put your sleep in a synchronized block as shown in THIS thread.
I'm curious why you don't trust waitFor in Windows. Are there known issues with that?
You might also search this thread for StreamGobbler. There were some good examples of reading stdout and errout from the process. I only did all this stuff once and I waited for the outputs to end rather than using waitFor(). The streams seemed to run a while after waitFor returned, maybe because they were buffered or something.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com