Is it possible to do a "C like" fork in java, using an new independent jvm process ?
How?
Fork system call is used for creating a new process, which is called child process, which runs concurrently with the process that makes the fork() call (parent process). After a new child process is created, both processes will execute the next instruction following the fork() system call.
In Java, the fork/join framework provides support for parallel programming by splitting up a task into smaller tasks to process them using the available CPU cores. In fact, Java 8's parallel streams and the method Arrays#parallelSort use under the hood the fork/join framework to execute parallel tasks.
In the computing field, fork() is the primary method of process creation on Unix-like operating systems. This function creates a new copy called the child out of the original process, that is called the parent. When the parent process closes or crashes for some reason, it also kills the child process.
Fork is a process in which a task splits itself into smaller and independent sub-tasks which can be executed concurrently.
This answer is probably a little late but:
http://akuma.kohsuke.org/
seems to be exactly what your looking for
Funnily, I am just working on this: a Java process running other Java processes. I used the article From Runtime.exec() to ProcessBuilder as a solid base, and When Runtime.exec() won't as a good advice how to gobble the output streams.
PS.: For those wondering, I had to do that (instead of spawning new threads) because yet another Java process is checking the presence of these processes which are, normally, ran separately with shell commands.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With