[英]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.