How to develop a JVM?

Possible duplicate:
C-Like Fork?

I wanted to know how to branch a child JVM from the JDK, or even this can be done?

Some frameworks, such as hadoop, deploy a child JVM for specific tasks, so skip some light on this.

Thanks!

+7
jvm
source share
2 answers

A fork is usually confused with caviar. Spawn is fork + exec (which means the beginning of a process that replaces the current one and inherits some of its external resources, such as open sockets).

Spawn is available in Java (via System.exec, etc.).

Fork is not in Java because it will be very problematic.

A fork requires address space cloning. Kernel support for efficient use is not available on most non-Unix systems; for example, U / win and Cygwin fought to emulate plugs under Win32. In a language such as Java, the garbage collector & amp; JIT compilers will touch Vmem pages, such as that the space will not remain divided after fork for a long time.

Cloning has many side effects. For example, input or output buffers will be processed in all forked children. SysV shared memory will be disconnected.

Most languages ​​and many libraries simply refuse forking support. This includes the Streaming API (POSIX); A child cannot use threads until he performs (i.e. becomes a spawn)!

Perl uses fork because its internal elements are very close to C / Unix, and its multithreading is horrific.

The Unix shell uses fork in design, as all local variables and state take snapshots of it. This is why there is no decent Unix shell for a non-Unix environment.

+13
source share

In general, I do not think that this is possible in the sense that you are talking about. You can System.exec() unscrew the new process and thus invoke the new JVM. Note that you can call fork() directly from your own code, but in the words of the poster here , "Do not. T."

+7
source share

All Articles