JVM中共享的内容 [英] What is shared in a JVM

查看:130
本文介绍了JVM中共享的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在同一Java虚拟机中运行的两个不同的Java程序如何共享?

What do two different Java programs, running in one same Java Virtual Machine, share together?

关于单例类,我想到了一些事情:每个JVM只能实例化一次.这意味着如果两个不同的Java程序使用同一个类,那么它们都将访问该Singleton类的相同实例?

Something comes to my mind, regarding singleton classes: They can only be instantiated once per JVM. This means that if two different Java programs use one same class, they are both accessing the same instance of that Singleton class?

还有什么共享的东西?

推荐答案

如果多次运行 java 命令,则将获得JVM的多个实例.从理论上讲,它们是完全独立的,没有共享,但是JVM的某些实现(现在或过去)可能会尝试共享数据的某些部分.

If you run the java command multiple times, you get multiple instances of the JVM. In theory these are entirely separate with nothing shared, but some implementations of the JVM (now or in the past) might attempt to share some portions of the data.

我最近没有看过它,但是大约10年前,有一个Sun JVM版本试图在JVM实例之间共享" .class文件映像. (据说这在可能同时运行数十个JVM且它们可能来来往往很快的服务器上很有用.)

I haven't looked at it recently, but about 10 years back there was a version of the Sun JVM that would attempt to "share" .class file images between JVM instances. (This was supposedly useful on servers where there might be dozens of JVMs running at once and they might come and go fairly rapidly.)

我没有回想起共享的任何其他数据,但是自那以后,可能有更多数据或添加了其他数据. (尽管实际上在JVM之间没有太多可以共享的东西.)

I'm not recalling any other data shared, but there may have been more, or other data may have been added since. (Though there really isn't much else that can be shared between JVMs.)

但是,从理论上讲,这应该都是透明的",并且不影响单个JVM实例的操作.

But again, in theory this should all be "transparent" and not affect the operation of an individual JVM instance.

还有一条热启动" JVM的规定,该JVM在最终命令之前已部分加载.确实需要系统管理员进行一些配置,但其他方面是透明的.

There was also a provision for "warm started" JVMs that were partially loaded prior to the final command. This did require some configuration on the part of the system admin, but was otherwise transparent.

这篇关于JVM中共享的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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