SeptemberHX
12/23/2018 - 3:23 PM

Java 单例模式

Java 单例类 Skeleton|-|&tag=Java

public class Skeleton {

	private static volatile Skeleton instance;
  
	private Skeleton() {
    }
    
    public static Skeleton getInstance() {
        if (instance == null) {
            synchronized (Skeleton.class) {
                if (instance == null) {
                    instance = new Skeleton();
                }
            }
        }
        return instance;
    }

}