C# 编码的双重检验锁定

// Port to C#
class Singleton {
 public static Singleton Instance() {
   if (_instance == null)//提高效率
       {
   lock (typeof(Singleton)) {
    if (_instance == null) //防止多次创建单例对象
              {
     _instance = new Singleton();
    }
   }
  }
return _instance;
}
protected Singleton() {
}
private static volatile Singleton _instance = null;
}
原文地址:https://www.cnblogs.com/bayonetxxx/p/1508643.html