Problem Runtime.exec()
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Matthew_Muller
Posted On:   Monday, January 26, 2004 05:42 PM

I am writing a Java program that relies heavily on calling other executables. I am using the Runtime.exec() method to call commands and then processing the input and error streams the come with the returned Process. I know that the InputStream.read() method blocks when when the input buffer is full so I spawn 2 new threads to read the input and error streams from the Process (Similar to the method cited in Michael Daconta's Javaworld article ) However, I still see the read() method block occasionally. Because the thread gets blocked it cannot terminate, so I end up with lots of threads just waiting on read(). What can I do to a Thread that is blocked this way? Is it possible that the buffer is filling up while the JVM is executing another thread? Is t   More>>

I am writing a Java program that relies heavily on calling other executables. I am using the Runtime.exec() method to call commands and then processing the input and error streams the come with the returned Process. I know that the InputStream.read() method blocks when when the input buffer is full so I spawn 2 new threads to read the input and error streams from the Process (Similar to the method cited in Michael Daconta's Javaworld article ) However, I still see the read() method block occasionally. Because the thread gets blocked it cannot terminate, so I end up with lots of threads just waiting on read(). What can I do to a Thread that is blocked this way? Is it possible that the buffer is filling up while the JVM is executing another thread? Is there a way to do IO from an another process that is 100% reliable?

It seems like I'm working way too hard to accomplish a fairly simple task. Any tips would be appreciated!

   <<Less

Re: Problem Runtime.exec()

Posted By:   Christopher_Koenigsberg  
Posted On:   Tuesday, January 27, 2004 07:16 AM

Sounds like maybe the external executables are not quitting/exiting?

About | Sitemap | Contact