Forking processes with Java

Can a complete "program" branch be created from a single execution sequence into two subroutines?

The subroutines are exactly the same They have the same execution order and values, but now they are two different programs This is like creating a clone of an object, which provides us with two different objects of the same type However, instead of just an object and some values, we create a fully parallel execution sequence of the program that has been loaded into the JVM (I prefer the Java answer)

Solution

You seem to be looking for the UNIX fork system call equivalent Java

This does not exist in Java, and it is not clear whether it is possible, because processes in UNIX have no direct equivalent in the JVM (threads are not as independent as processes)

However, a fork framework is planned for Java 7:

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

It's different from UNIX's fork / join, but it shares some ideas and may be useful

Of course, you can use Java for concurrent programming. It is not done through fork (), but using threads

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>