日期:2014-05-17 浏览次数:20812 次
public class Singleton
{
private static Singleton instance;
private Singleton()
{
}
public static Singleton GetInstance()
{
if(instance==null)
{
instance=new Singleton();
}
return instance;
}
}
public class testClass
{
private testClass()
{
}
private static object _obj = new object();
private static testClass _instance = null;
public static testClass Instance()
{
if (_instance == null)
{
lock (_obj)
{
if (_instance == null)
{
_instance = new testClass();
}
}
}
return _instance;
}
}