单例模式标准写法 (注意volatile不能少掉):
public sealed class Singleton
{
static <span style="color:#ff0000;">volatile </span>Singleton instance=null;
static readonly object padlock = new object();
Singleton()
{
}
public static Singleton Instance
{
get
{
if (instance==null)
{
lock (padlock)
{
if (instance==null)
{
instance = new Singleton();
}
}
}
return instance;
}
}
}
http://www.yoda.arachsys.com/csharp/singleton.html