About JVM creation
When does the instance of JVM created? If 2 JVMs running parallel in the 开发者_如何学编程same system,whether the program that running in one Jvm can access the program that is running in another one? I heard that this is true. Is that so?
Two JVMs can only talk to each other using inter-process communication methods, just as two non-JVM processes would do.
i.e. they need to use a shared database, a message queue, sockets -- or even plain files to share data.
No, it is not true. You'll have two strictly separated virtual machines and objects living in one VM can't send messages to objects living in the other one or share data.
The virtual machine is started/created/... when you call java
.
One instance of JVM is created per process. That is, one independent instance is created every time you run java.exe
. Such JVMs are completely separate of each other, therefore you can even run different versions of JVM on the same machine.
There is no transparent way for JVMs to communicate with each other. However, java comes bundled with RMI, an inter-process communication tool, which allows almost transparent cross-JVM communication. But of course it involves specifying other JVM's hostname and port of communication, so you need to a bit of work to get it to work correctly.
精彩评论