static void Main(string[] args) { Console.WriteLine("first access to an instance BigObject"); Console.WriteLine(BigObject.GetInstance() + " " + BigObject.GetInstance().GetHashCode()); Console.WriteLine("second access to an instance BigObject"); Console.WriteLine(BigObject.GetInstance() + " " + BigObject.GetInstance().GetHashCode()); }
public static BigObject GetInstance() { if (instance == null) { lock (typeof(BigObject)) { if (instance == null) { instance = new BigObject(); } } } return(instance); }