[LinkedIn] singleton, thread safe
//thread safe singleton. static makes it guarantee that it only gets created at the first time
public class Singleton {
public final static Singleton INSTANCE = new Singleton();
private Singleton() {
// Exists only to defeat instantiation.
}
}
//how to use it.
Singleton singleton = Singleton.INSTANCE;
singleton.dothis();
singleton.dothat();