标签:des style blog color 使用 strong for ar
public class Singleton { static public Singleton instance ; // 唯一实例 protected Singleton () { } //封闭客户程序的直接实例化 public static Singleton Instance //全局访问点 { get { if ( instance == null) instance = new Singleton(); return instance; } } }
public class Singleton { protected Singleton (){} static volatile Singleton instance = null ; //Lazy方式创建唯一实例的过程 public static Singleton Instance() { if(instance == null ) //外层 if lock(typeof(Singleton)) //多线程中共享资源同步 if(instance == null ) // 内层if instance = new Singleton(); return instance; } }
sealed class Singleton { Singleton() { } public static readonly Singleton Instance = new Singleton(); }
public class BaseEntity : System .ICloneable { public object Clone() //对当前实例进行克隆 { return this .MemberwiseClone(); } } public class Singleton : BaseEntity { //... }
标签:des style blog color 使用 strong for ar
原文地址:http://www.cnblogs.com/chenwz91/p/3888585.html