随笔 - 63  文章 - 0  评论 - 7 
  2010年12月22日
posted @ 2010-12-22 16:07 Atom Yan 阅读(11) 评论(0) 编辑
Link: http://msdn.microsoft.com/en-us/library/ms998558.aspx

using System;

public sealed class Singleton
{
private static volatile Singleton instance;
private static object syncRoot = new Object();

private Singleton() {}

public static Singleton Instance
{
get
{
if (instance == null)
{
lock (syncRoot)
{
if (instance == null)
instance = new Singleton();
}
}

return instance;
}
}
}
posted @ 2010-12-22 16:04 Atom Yan 阅读(46) 评论(0) 编辑