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

Posted By:   Sam_Eastburn
Posted On:   Monday, March 22, 2004 03:54 AM

Hi,

The problem is that i have written a web application and when running there may be multiple simultaneous executions of an external program that then returns output to the client. I use the above command to run the program and then use process.getInputStream() to return the output of the program. This means there are sometimes multiple instances of the class that calls, Runtime.getRuntime.exec(cmd). Does anybody know if the two calls to the Runtime class will interfere as it says in the Java API that there is only a single instance of this class? Thanks for any help in advance,

Sam

Re: Runtime.getRuntime.exec(cmd)

Posted By:   Glenn_Mason  
Posted On:   Thursday, April 1, 2004 03:43 PM

From the sounds of the javadoc, exec returns a Process object that maps to an underlying subprocess ie. a separate thread for each system process.


So each Process object returned is separate, therefore process.getInputStream() in each Java thread will be talking to a different Process object, and won't interfere!


If you're really worried, wrap the call to exec in a synchronized block.

About | Sitemap | Contact