public class MyClass
{
static MyClass cache = null;
static object cacheLock = new object();
private MyClass()
{
// useful stuff here
}
public static MyClass GetMyClass()
{
lock(cacheLock)
{
if (cache == null)
cache = new MyClass();
return(cache);
}
}
}