package cn.bunny.pattern1;

public class Singleton1 {
    private static volatile Singleton1 instance;

    private Singleton1() {
        // 构造函数私有化
    }

    public static Singleton1 getInstance() {
        if (instance == null) { // 第一次检查
            synchronized (Singleton1.class) {
                if (instance == null) { // 第二次检查
                    instance = new Singleton1();
                }
            }
        }
        return instance;
    }
}