fork process in Java

J

JJ

Hello:

Besides Runtime.exec("executiable name"), what are the other ways to
"fork a process" in Java.

Thanks.

JJ
 
R

Roedy Green

Besides Runtime.exec("executiable name"), what are the other ways to
"fork a process" in Java.

you can start a Thread which is internal to the JVM.

That's it as far as I know. Anything else would be platform specific
and require JNI.
 
P

Peter Jones

JJ said:
Hello:

Besides Runtime.exec("executiable name"), what are the other ways to
"fork a process" in Java.

Thanks.

JJ
As far as I'm aware, you "fork" a process by using threads. You'ld have to
Google it more though, thats as far as I know. Hope it helps
 
W

Wibble

Peter said:
JJ wrote:



As far as I'm aware, you "fork" a process by using threads. You'ld have to
Google it more though, thats as far as I know. Hope it helps
A thread isn't a processess. The only way other
than Runtime.exec is to write JNI code (java native interface).

You probably dont really want to fork a process, right?
 
T

Thomas Weidenfeller

JJ said:
Besides Runtime.exec("executiable name"), what are the other ways to
"fork a process" in Java.

The almost unknown java.lang.ProcessBuilder

Don't ask me why Sun added this in 1.5.

/Thomas
 
T

tom fredriksen

JJ said:
Hello:

Besides Runtime.exec("executiable name"), what are the other ways to
"fork a process" in Java.

AFAIK, there is no fork concept in java, thats a unix thing. The only
concepts available are starting a new application (exec) and starting
new threads. There might be some library that have implemented fork etc
through jni (I know there is for posix pipes, shared memory etc.), that
would give you almost the full power of fork and the unix process
concept. But sadly its not supported in java.

/tom
 
T

Thomas Hawtin

tom said:
AFAIK, there is no fork concept in java, thats a unix thing. The only
concepts available are starting a new application (exec) and starting
new threads. There might be some library that have implemented fork etc
through jni (I know there is for posix pipes, shared memory etc.), that
would give you almost the full power of fork and the unix process
concept. But sadly its not supported in java.

Indeed, Windows creates new processes rather than forks (although
presumably it can do some kind of fudged fork for POSIX). I don't like
the chances of the JRE keeping it together if you try to use it from
both legs.

Tom Hawtin
 
J

James McGill

AFAIK, there is no fork concept in java, thats a unix thing.

A fork() would amount to a copy of the JVM. I get no further than that
when I realize it's too complicated to even think about.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top