The code itself its self-explanatory.
However I found it here:
Pasted code below:
public static class Singleton
{
private static readonly object syncRoot = new object();
private static T instance;
public static T Instance
{
get
{
if (instance == null)
{
lock (syncRoot)
{
if (instance == null)
{
var tempInstance = new T();
Thread.MemoryBarrier();
instance = tempInstance;
}
}
}
return instance;
}
}
}
No comments:
Post a Comment