views:

69

answers:

2

Hi there, is it possible to start a new thread in a different process in Java? I mean, I'm running a specific process and main thread, issuing ProcessBuilder for creating a new process. Before start() method is invoked, one must provide the command to be run in another process. Is it possible to start a new thread in newly created process?

Thank you in advance for the reply.

Best regards.

+1  A: 

You need the cooperation of the other process. Some code there must do the actual thread starting. You could pass a command line argument to the new process, or have it make a socket available for a chat so it can ask what to do. The latter option could be implemented using common inter-process techniques such as messaging or HTTP-based web services.

For a simple bootstrap kind of scenario command line args could be enough.

djna
A: 

No - that is unless you have the source code of the process you are launching with ProcessBuilder. if you do have the source code, add the new thread there.

Shuky Kappon