示例#1
0
 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());
 }
示例#2
0
 public static BigObject GetInstance()
 {
     if (instance == null)
     {
         lock (typeof(BigObject)) {
             if (instance == null)
             {
                 instance = new BigObject();
             }
         }
     }
     return(instance);
 }