单例设计模式 同步问题

class Single
{
    private static Single s=null;
    private Single(){}
    public static Single getInstance()
    {
        if(s==null)
        {
            synchronized(Single.class)
            {
                if(s==null)
                    s=new Single();
            }
        }
        return s;
    }
}

猜你喜欢

转载自www.cnblogs.com/zhujialei123/p/9350785.html
今日推荐