public void TestTryLock() { ReentrantLock rl = new ReentrantLock(); Assert.IsTrue(rl.TryLock()); Assert.IsTrue(rl.IsLocked); rl.UnLock(); }
private void TestTryLockTimeoutRunnable(Object state) { ReentrantLock locker = state as ReentrantLock; try { ThreadAssertFalse(locker.TryLock(1)); } catch (Exception e) { ThreadUnexpectedException(e); } }
private void TestInterruptedException2Runnable(Object state) { ReentrantLock locker = state as ReentrantLock; try { locker.TryLock(MEDIUM_DELAY_MS); ThreadShouldThrow(); } catch (ThreadInterruptedException) { } }
private void TestTryLockWhenLockedRunnable(Object state) { ReentrantLock locker = state as ReentrantLock; ThreadAssertFalse(locker.TryLock()); }