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