public class Singleton
{
private readonly object _lockObj = new object();
private static Singleton Instance;
private Singleton()
{
}
public static Singleton GetInstance()
{
if (Instance == null)
{
Instance = new Singleton();
}
return Instance;
}
}
public class LockSingleton
{
private static LockSingleton Instance;
private LockSingleton()
{
}
public static LockSingleton GetInstance()
{
if (Instance == null)
{
lock(_lockObj)
{
if (Instance == null)
{
Instance = new LockSingleton();
}
}
}
return Instance;
}
}
public class AngrySingleton
{
private static LockSingleton Instance = new LockSingleton();
private LockSingleton()
{
}
public static LockSingleton GetInstance()
{
return Instance;
}
}