用Java分叉进程 [英] Forking a process in Java

查看:81
本文介绍了用Java分叉进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以从单个执行序列中创建执行中的'PROGRAM'的完整分支到两个子程序中?

Is it possible to create a complete fork of a 'PROGRAM' in execution into two sub-programs from a single execution sequence ?

制作的子程序完全相同。它们具有相同的执行顺序和值,但现在它们是两个不同的程序。这就像创建一个Object的克隆,从而为我们提供了两个相同类型的不同对象。但是,我们不是只是一个对象和一些值,而是在这里创建一个已经在JVM中加载的程序的完全并行执行序列(更喜欢Java的答案)。

The sub-programs produced are completely identical. They have the same execution sequences and values but now they are two different programs. It is like creating a clone of an Object, thus giving us two different objects of the same type to work on. But instead of just an object and some values, here we want to create a completely parallel execution sequence of a Program already loaded in the JVM (would prefer an answer for Java).

推荐答案

您似乎在寻找与 fork系统调用

这在Java中是不存在的,并且不清楚它是否可能,因为Unix中的进程不存在在JVM中具有直接等价物(线程不如进程独立)。

That does not exist in Java, and it's unclear whether it would even be possible, as processes in Unix don't have a direct equivalent in the JVM (threads are less independent than processes).

然而,为Java 7计划了一个fork框架:

There is however a fork framework planned for Java 7:

http://www.ibm.com/developerworks/java/library/j-jtp11137.html

它与Unix'es fork / join不同,但它有一些想法并且可能有用。

It's not the same as Unix'es fork/join, but it shares some ideas and might be useful.

当然你可以用Java进行并发编程,它不是通过fork()完成的,而是使用Threads。

Of course you can do concurrent programming in Java, it's just not done via fork(), but using Threads.

这篇关于用Java分叉进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆