中国开发网: 论坛: .NET/C#: 贴子 636285
qyuhen: 你这个不是多线程安全版本,呵呵。
public static class Singleton<T>
where T : class, new()
{
private static T instance;
private static object o = new object();

public static T Instance
{
get
{
if (instance == null)
{
lock (o)
{
if (instance == null)
instance = new T();
}
}

return instance;
}
}
}

相关信息:


欢迎光临本社区,您还没有登录,不能发贴子。请在 这里登录