You are viewing a single comment's thread. Return to all comments →
I think Bill Pugh Singleton Implementation is best implementation for singleton.
public class BillPughSingleton { private BillPughSingleton() { // private constructor } private static class SingletonHelper{ private static final BillPughSingleton INSTANCE = new BillPughSingleton(); } public static BillPughSingleton getInstance(){ return SingletonHelper.INSTANCE; } }
You need to take care of Serialization,reflection and cloning as well. More on this.Singleton design pattern
Seems like cookies are disabled on this browser, please enable them to open this website
Java Singleton Pattern
You are viewing a single comment's thread. Return to all comments →
I think Bill Pugh Singleton Implementation is best implementation for singleton.
You need to take care of Serialization,reflection and cloning as well. More on this.Singleton design pattern