Singleton in Java Is A Class With Just One Instance in Whole Java Application How To Create Thread-Safe Singleton in Java
Singleton in Java Is A Class With Just One Instance in Whole Java Application How To Create Thread-Safe Singleton in Java
You can also refer What is Factory method design pattern in Java to know more details.
10. What is Singleton? is it better to make whole method synchronized or only critical section
synchronized ?
Singleton in Java is a class with just one instance in whole Java application, for
example java.lang.Runtime is a Singleton class. Creating Singleton was tricky prior Java 4 but once Java 5
introduced Enum its very easy. see my article How to create thread-safe Singleton in Java for more details
on writing Singleton using enum and double checked locking which is purpose of this Java interview
question.