Singleton Factory

Singleton factory for single threaded environment: It is simple to create Singleton factory for single threaded application. public class SingleThreadSingleton { private static SingleThreadSingleton instance; private SingleThreadSingleton() { // Initialise } public static SingleThreadSingleton getInstance() { if (instance == null) { instance = new SingleThreadSingleton(); } return instance; } } Singleton factory for multi threaded application: When you want to create Singleton factory for multi threaded application. In which you want single instance to be maintained across all thread. [Read More]