Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.
When an Application is Distributed across multiple JVMS my single ton class will have multiple instances at each JVM. I will have to generate a Unique ID for this purpose i have to use a singleton pattern class. We can use a central place (like database) to generate the ids. Of course you need to do appropriate locking on the resource so that it is modified by only one entity at a time.
Another Solution would be to use Spring GemFire approach or to use Java NIO package for more fine grained approach.
Singleton pattern is a design solution where an application wants to have one and only one instance of any class, in all possible scenarios without any exceptional condition. It has been debated long enough in java community regarding possible approaches to make any class singleton. Still, you will find people not satisfied with any solution you give. They can not be overruled either. In this post, we will discuss some good approaches and will work towards our best possible effort.