Exemple #1
0
        static void Main(string[] args)
        {
            Adam adam = Adam.GetInstance();
            Eve  eve  = Eve.GetInstance(adam);

            Console.WriteLine(adam.Name);
            Console.WriteLine(eve.Name);
            Console.ReadLine();
        }
Exemple #2
0
 public static Eve GetInstance(Adam adam)
 {
     lock (locker)
     {
         if (adam == null)
         {
             throw new ArgumentNullException();
         }
         if (uniqueInstance == null)
         {
             uniqueInstance = new Eve("Eve");
         }
         return(uniqueInstance);
     }
 }