Пример #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();
 }