Singleton class, thread-safe lazy loading.

Seven ways to write singleton mode:
http://cantellow.iteye.com/blog/838473

Double check lock:
public class Singleton {

	private volatile static Singleton singleton;  
    private Singleton (){}  
    public static Singleton getSingleton() {  
	    if (singleton == null) {  
	        synchronized (Singleton.class) {  
		        if (singleton == null) {  
		            singleton = new Singleton();  
		        }  
	        }  
	    }  
	    return singleton;  
	}  
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326033309&siteId=291194637