예제 #1
0
        public void TestTryLock()
        {
            ReentrantLock rl = new ReentrantLock();

            Assert.IsTrue(rl.TryLock());
            Assert.IsTrue(rl.IsLocked);
            rl.UnLock();
        }
예제 #2
0
        private void TestTryLockTimeoutRunnable(Object state)
        {
            ReentrantLock locker = state as ReentrantLock;

            try
            {
                ThreadAssertFalse(locker.TryLock(1));
            }
            catch (Exception e)
            {
                ThreadUnexpectedException(e);
            }
        }
예제 #3
0
        private void TestInterruptedException2Runnable(Object state)
        {
            ReentrantLock locker = state as ReentrantLock;

            try
            {
                locker.TryLock(MEDIUM_DELAY_MS);
                ThreadShouldThrow();
            }
            catch (ThreadInterruptedException)
            {
            }
        }
예제 #4
0
        private void TestTryLockWhenLockedRunnable(Object state)
        {
            ReentrantLock locker = state as ReentrantLock;

            ThreadAssertFalse(locker.TryLock());
        }
예제 #5
0
 public void TestTryLock()
 {
     ReentrantLock rl = new ReentrantLock();
     Assert.IsTrue(rl.TryLock());
     Assert.IsTrue(rl.IsLocked);
     rl.UnLock();
 }