0

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.

E.g if i add/remove an element to Hashmap

Does the change/modification impact the instances on other class loaders as well?

user3587174
  • 661
  • 3
  • 8
  • 13

2 Answers2

0

Your "singleton" is one instance per JVM.

Here is a good article discussing classloaders, the relationship between different classloaders to each other, and to the JVM:

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

FoggyDay
  • 11,962
  • 4
  • 34
  • 48
  • Thanks! for your reply. I understand the concept of class loader rules and the relation ship between different classloaders. Singleton is only one instance per classloader and the jvm can have multiple class loaders right? My question is if i have any changes to one instance, will that impact other instances in other class loaders. – user3587174 May 03 '14 at 19:50
  • Two other references: [Singleton class with several different classloaders](http://stackoverflow.com/questions/15156840/singleton-class-with-several-different-classloaders) and [When is a Singleton not a Singleton?](http://www.oracle.com/technetwork/articles/java/singleton-1577166.html) – FoggyDay May 04 '14 at 03:31
0

Singleton is per classloader. so changes wont impact other instances loaded using other classloaders.

there are couple of good references:

Community
  • 1
  • 1
Anirban Basak
  • 193
  • 1
  • 4