Java - C-Like Fork?

2020-01-27 02:11发布

Is it possible to do a "C like" fork in java, using an new independent jvm process ?

How?

标签: java c fork
3条回答
仙女界的扛把子
2楼-- · 2020-01-27 02:45

This answer is probably a little late but:

http://akuma.kohsuke.org/

seems to be exactly what your looking for

查看更多
我想做一个坏孩纸
3楼-- · 2020-01-27 02:55

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.

查看更多
混吃等死
4楼-- · 2020-01-27 03:01

The Application Isolation API (JSR 121) introduces Isolate which addresses this use case.

查看更多
登录 后发表回答