标签:style blog color sp on div log bs ad
public class Singleton { private static Singleton _instance; private static readonly object syn = new object(); private Singleton() //构造函数设置private,不能被new,单例模式 { } public static Singleton CreateInstance() { if (_instance == null) { lock (syn) //加锁防止多线程 { if (_instance == null) { _instance = new Singleton(); } } } return _instance; } }
标签:style blog color sp on div log bs ad
原文地址:http://www.cnblogs.com/han1982/p/4129648.html