下面列出了java.util.concurrent.locks.ReentrantReadWriteLock#hasWaiters() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public void testHasWaitersNPE(boolean fair) {
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(fair);
try {
lock.hasWaiters(null);
shouldThrow();
} catch (NullPointerException success) {}
}
public void testHasWaitersIAE(boolean fair) {
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(fair);
final Condition c = lock.writeLock().newCondition();
final ReentrantReadWriteLock lock2 = new ReentrantReadWriteLock(fair);
try {
lock2.hasWaiters(c);
shouldThrow();
} catch (IllegalArgumentException success) {}
}
public void testHasWaitersIMSE(boolean fair) {
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(fair);
final Condition c = lock.writeLock().newCondition();
try {
lock.hasWaiters(c);
shouldThrow();
} catch (IllegalMonitorStateException success) {}
}
public void testHasWaitersNPE(boolean fair) {
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(fair);
try {
lock.hasWaiters(null);
shouldThrow();
} catch (NullPointerException success) {}
}
public void testHasWaitersIAE(boolean fair) {
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(fair);
final Condition c = lock.writeLock().newCondition();
final ReentrantReadWriteLock lock2 = new ReentrantReadWriteLock(fair);
try {
lock2.hasWaiters(c);
shouldThrow();
} catch (IllegalArgumentException success) {}
}
public void testHasWaitersIMSE(boolean fair) {
final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(fair);
final Condition c = lock.writeLock().newCondition();
try {
lock.hasWaiters(c);
shouldThrow();
} catch (IllegalMonitorStateException success) {}
}