public void IsQueuedThreadReportsWhetherThreadIsQueued(bool isFair) { _lock = new ReentrantLock(isFair); Thread t1 = ThreadManager.NewManagedThread(InterruptedLock, "T1"); Thread t2 = ThreadManager.NewManagedThread(InterruptibleLock, "T2"); Assert.IsFalse(_lock.IsQueuedThread(t1)); Assert.IsFalse(_lock.IsQueuedThread(t2)); _lock.Lock(); t1.Start(); Thread.Sleep(Delays.Short); Assert.IsTrue(_lock.IsQueuedThread(t1)); t2.Start(); Thread.Sleep(Delays.Short); Assert.IsTrue(_lock.IsQueuedThread(t1)); Assert.IsTrue(_lock.IsQueuedThread(t2)); t1.Interrupt(); Thread.Sleep(Delays.Short); Assert.IsFalse(_lock.IsQueuedThread(t1)); Assert.IsTrue(_lock.IsQueuedThread(t2)); _lock.Unlock(); Thread.Sleep(Delays.Short); Assert.IsFalse(_lock.IsQueuedThread(t1)); Thread.Sleep(Delays.Short); Assert.IsFalse(_lock.IsQueuedThread(t2)); ThreadManager.JoinAndVerify(t1, t2); }
public void IsQueuedThreadChokesOnNullParameter(bool isFair) { ReentrantLock sync = new ReentrantLock(isFair); sync.IsQueuedThread(null); }