简体   繁体   English

更改对不同类加载器加载的单例类的影响

[英]Impact of changes on singleton class loaded by different classloaders

If i have multiple instances of singleton class on different class loaders 如果我在不同的类加载器上有单例类的多个实例
and if i have modifications to a reference variable in any of these instances. 并且如果我在任何这些情况下都对参考变量进行了修改。

Eg if i add/remove an element to Hashmap 例如,如果我向Hashmap中添加/删除元素

Does the change/modification impact the instances on other class loaders as well? 更改/修改是否也会对其他类加载器上的实例产生影响?

Your "singleton" is one instance per JVM. 您的“单例”是每个JVM一个实例。

Here is a good article discussing classloaders, the relationship between different classloaders to each other, and to the JVM: 这是一篇很好的文章,讨论了类加载器,不同的类加载器之间以及与JVM之间的关系:

http://javapapers.com/core-java/java-class-loader/ http://javapapers.com/core-java/java-class-loader/

Singleton is per classloader. Singleton是每个类加载器。 so changes wont impact other instances loaded using other classloaders. 因此更改不会影响使用其他类加载器加载的其他实例。

there are couple of good references: 有几个很好的参考:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 具有多个不同类加载器的单例类 - Singleton class with several different classloaders 检测不同ClassLoader加载的类的Class对象等效性 - Detecting Class object equivalence for classes loaded by different ClassLoaders 在Spring Boot和Logback中由不同的Classloader加载的类 - Classes loaded by different Classloaders in Spring Boot and Logback 如果一个类是由不同的类加载器加载的,那么(sun-jvm)热点优化会发生多次吗? - Does (sun-jvm) hotspot optimization take place multiple times, if a class is loaded by different classloaders? 如何使用两个不同的类加载器加载同一类 - How to load same class with two different classloaders 从不同ClassLoader加载的类访问静态方法 - Access static method from classes loaded by different ClassLoaders Spring Data,EclipseLink和SimpleLoadTimeWeaver; 由不同的ClassLoader加载的域类 - Spring Data, EclipseLink, and SimpleLoadTimeWeaver; domain classes loaded by different ClassLoaders 即使类由类加载器加载,也会发生ClassDefNotFoundException(服务器上安装了多个应用程序) - ClassDefNotFoundException even though the class is loaded by the classloaders (Multiple Applications are installed on the Server) 使用两个不同的类加载器来加载相同类的两个孩子 - Using two different classloaders to load two children of the same class 单例课程的不同锁 - Different locks for a singleton class
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM