public sealed class CachingService
{ //syncIndicator. -- thread synchonization
private static readonly object syncObject = new object();
//The unique instance. -- volatile to allow multi-threading
private static volatile CachingService serviceInstance;
//Blank default constructor
private CachingService(){}
public static CachingService Value
{ get
{ //in multi-threads, the next statement result will be different,
//because of the execution sequence
if(serviceInstance == null)
{ lock(syncObject)
{ if(serviceInstance == null)
serviceInstance = new CachingService();
}
}
return serviceInstance;
}//end of get
}//end of Value property
}