Static objects are initialized only once. Singleton classes are instantiated only once. If we use a singleton in a cluster then it will create multiple instances of singleton in the clusters. So what happens to the static object in a cluster environment? Why this object is not initialized in other cluster servers? or why the objects state doesn't change?
Static Objects are always in the scope of the ClassLoader (in most cases per JVM) and are not regarded in clustering. If you need a Singleton you have to tell the container to create one. It depends on the nature of your Singleton if it should exist only one per Cluster or once per JVM or once per Classloader.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With