예제 #1
0
 public override void Lock()
 {
     while (true)
     {
         WaitUnlocked();
         if (Atomic.TestAndSet(ref flag, Locked, Unlocked))
         {
             break;
         }
     }
 }
예제 #2
0
        public override void Lock()
        {
            while (true)
            {
                while (locked == 1)
                {
                }

                if (Atomic.TestAndSet(ref locked, 1, 0))
                {
                    break;
                }
            }
        }
예제 #3
0
 public override void Lock()
 {
     while (!Atomic.TestAndSet(ref locked, 1, 0))
     {
     }
 }