设计模式之单例设计模式

来源:互联网 发布:丝路英雄葱岭冒险数据 编辑:程序博客网 时间:2024/05/01 22:04
public class Singleton {    private Singleton(){ }    private volatile static Singleton instance;    public static Singleton getInstance(){        if(instance == null){            synchronized (Singleton.class) {                if(instance == null){                    instance = new Singleton();                }            }        }        return instance;    }}
原创粉丝点击