This was the example from me in a training session. I was the trainer and explaining singleton class in multi-threaded environment to batch of 20 new joiners and someone ask me- is there some readily available singleton classes in java - api? And i was like..hmm and bla bla?
Can someone help me..
Campbell Ritchie wrote:There are lots of enums. Since all their instances are intentionally distinct, that is similar to Singletons.
System class.No, that isn't a singleton because it always has exactly 0 instances.
As per my understanding, Enums are a way to create Singleton classes, not itself it is Singleton.
The database connection classes are singleton.
Thread pooling classes are singleton.
Ravi Desigan wrote:The logging classes (log4j, etc) are Singleton.
Since when they started bundling it with Java API?