本文整理了Java中java.util.concurrent.locks.ReentrantReadWriteLock.hasQueuedThreads
方法的一些代码示例,展示了ReentrantReadWriteLock.hasQueuedThreads
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ReentrantReadWriteLock.hasQueuedThreads
方法的具体详情如下:
包路径:java.util.concurrent.locks.ReentrantReadWriteLock
类名称:ReentrantReadWriteLock
方法名:hasQueuedThreads
[英]Queries whether any threads are waiting to acquire the read or write lock. Note that because cancellations may occur at any time, a true return does not guarantee that any other thread will ever acquire a lock. This method is designed primarily for use in monitoring of the system state.
[中]查询是否有线程正在等待获取读或写锁。请注意,由于取消操作可能随时发生,因此真正的返回并不保证任何其他线程都会获得锁。该方法主要用于监控系统状态。
代码示例来源:origin: apache/asterixdb
boolean hasWaiters() {
return latch.hasQueuedThreads();
}
代码示例来源:origin: stackoverflow.com
if(lock.hasQueuedThreads()){
代码示例来源:origin: net.sf.jstuff/jstuff-core
public void run() {
final HashLockManager<T> mgr = ref.get();
if (mgr == null) {
// if the corresponding HashLockManager was garbage collected we can cancel the scheduled execution of cleanup task
future.cancel(true);
return;
}
try {
for (final Iterator<Entry<T, ReentrantReadWriteLock>> it = mgr.locksByKey.entrySet().iterator(); it.hasNext();) {
final ReentrantReadWriteLock lock = it.next().getValue();
synchronized (lock) { // exclusive access to the lock object
final boolean isLockInUse = lock.isWriteLocked() || lock.getReadLockCount() > 0 || lock.hasQueuedThreads();
if (!isLockInUse) {
it.remove();
}
}
}
} catch (final Exception ex) {
LOG.error(ex, "Unexpected exception occured while cleaning lock objects.");
}
}
}
代码示例来源:origin: ch.cern.hadoop/hadoop-hdfs
assertFalse(nn1.getNamesystem().getFsLockForTests().hasQueuedThreads());
assertFalse(nn1.getNamesystem().getFsLockForTests().isWriteLocked());
assertTrue(nn1.getNamesystem().getCpLockForTests().hasQueuedThreads());
内容来源于网络,如有侵权,请联系作者删除!