• 设计模式 单例模式


    单例模式 (Singleton),保证一个类只有一个实例,并提供一个访问他的全局访问点。

        class Singleton
        {
            private static Singleton instance;
            private static readonly object syncRoot = new object();
            private Singleton()
            {
            }
    
            public static Singleton GetInstance()
            {
                if (instance == null)
                {
    
                    lock (syncRoot)
                    {
    
                        if (instance == null)
                        {
                            instance = new Singleton();
                        }
                    }
                }
                return instance;
            }
    
        }
    单例模式
  • 相关阅读:
    Gitbook
    Docker命令
    sd
    文本三剑客
    2017.4.12下午
    2017.4.11下午
    2017.4.11上午
    2017.4.10下午
    2017.4.10上午
    2017.4.7下午
  • 原文地址:https://www.cnblogs.com/YuanSong/p/4162457.html
Copyright © 2020-2023  润新知