本文整理了Java中java.util.concurrent.locks.ReentrantLock.isLocked
方法的一些代码示例,展示了ReentrantLock.isLocked
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ReentrantLock.isLocked
方法的具体详情如下:
包路径:java.util.concurrent.locks.ReentrantLock
类名称:ReentrantLock
方法名:isLocked
[英]Queries if this lock is held by any thread. This method is designed for use in monitoring of the system state, not for synchronization control.
[中]查询此锁是否由任何线程持有。该方法设计用于监控系统状态,而不是同步控制。
代码示例来源:origin: google/guava
/**
* Returns whether this monitor is occupied by any thread. This method is designed for use in
* monitoring of the system state, not for synchronization control.
*/
public boolean isOccupied() {
return lock.isLocked();
}
代码示例来源:origin: prestodb/presto
/**
* Returns whether this monitor is occupied by any thread. This method is designed for use in
* monitoring of the system state, not for synchronization control.
*/
public boolean isOccupied() {
return lock.isLocked();
}
代码示例来源:origin: google/j2objc
/**
* Returns whether this monitor is occupied by any thread. This method is designed for use in
* monitoring of the system state, not for synchronization control.
*/
public boolean isOccupied() {
return lock.isLocked();
}
代码示例来源:origin: wildfly/wildfly
public int getNumLocked() {
int retval=0;
for(Lock lock: locks)
if(((ReentrantLock)lock).isLocked())
retval++;
return retval;
}
代码示例来源:origin: wildfly/wildfly
/**
* Returns whether this monitor is occupied by any thread. This method is designed for use in
* monitoring of the system state, not for synchronization control.
*/
public boolean isOccupied() {
return lock.isLocked();
}
代码示例来源:origin: thinkaurelius/titan
@Override
public boolean inUse() {
return super.isLocked() || super.hasQueuedThreads();
}
代码示例来源:origin: org.apache.hadoop/hadoop-common
/**
* A wrapper method that makes a call to {@code isLocked()} of
* the underlying {@code ReentrantLock} object.
*
* Queries if this lock is held by any thread. This method is
* designed for use in monitoring of the system state,
* not for synchronization control.
*
* @return {@code true} if any thread holds this lock and
* {@code false} otherwise
*/
@VisibleForTesting
boolean isLocked() {
if (lock instanceof ReentrantLock) {
return ((ReentrantLock)lock).isLocked();
}
throw new UnsupportedOperationException();
}
代码示例来源:origin: JanusGraph/janusgraph
@Override
public boolean inUse() {
return super.isLocked() || super.hasQueuedThreads();
}
代码示例来源:origin: org.apache.spark/spark-core_2.11
assert (stateChangeLock.isLocked());
waitForAsyncReadComplete();
if (isEndOfStream()) {
代码示例来源:origin: org.apache.spark/spark-core
assert (stateChangeLock.isLocked());
waitForAsyncReadComplete();
if (isEndOfStream()) {
代码示例来源:origin: apache/geode
@After
public final void interruptStuckThreads() throws Exception {
server1.invoke(() -> {
if (stuckThread != null) {
stuckThread.interrupt();
}
stuckThread = null;
});
server2.invoke(() -> {
if (stuckThread != null) {
stuckThread.interrupt();
}
stuckThread = null;
});
// Wait to allow the locks to be released to avoid environment pollution for tests that follow
server1.invoke(() -> {
await().until(() -> !LOCK.isLocked());
});
server2.invoke(() -> {
await().until(() -> !LOCK.isLocked());
});
}
代码示例来源:origin: apache/hbase
@VisibleForTesting
boolean rollWriter(long logId) throws IOException {
assert logId > flushLogId : "logId=" + logId + " flushLogId=" + flushLogId;
assert lock.isHeldByCurrentThread() : "expected to be the lock owner. " + lock.isLocked();
代码示例来源:origin: org.eclipse.jetty/jetty-util
/**
* @return whether this lock has been acquired
*/
public boolean isLocked()
{
return _lock.isLocked();
}
代码示例来源:origin: net.sf.ehcache/ehcache
private boolean isLocked() {
return lock.isLocked();
}
代码示例来源:origin: magefree/mage
public boolean isLocked() {
return lock.isLocked();
}
代码示例来源:origin: nostra13/Android-Universal-Image-Loader
if (loadFromUriLock.isLocked()) {
L.d(LOG_WAITING_FOR_IMAGE_LOADED, memoryCacheKey);
代码示例来源:origin: apache/hbase
@After
public void tearDownAfterTest() throws IOException {
for (RegionInfo region : UTIL.getAdmin().getRegions(TABLE_NAME)) {
RegionStateNode regionNode = AM.getRegionStates().getRegionStateNode(region);
// confirm that we have released the lock
assertFalse(((ReentrantLock) regionNode.lock).isLocked());
TransitRegionStateProcedure proc = regionNode.getProcedure();
if (proc != null) {
regionNode.unsetProcedure(proc);
}
}
}
代码示例来源:origin: biezhi/learn-java8
public static void main(String[] args) {
ExecutorService executor = Executors.newFixedThreadPool(2);
ReentrantLock lock = new ReentrantLock();
executor.submit(() -> {
lock.lock();
try {
ConcurrentUtils.sleep(1);
} finally {
lock.unlock();
}
});
executor.submit(() -> {
System.out.println("Locked: " + lock.isLocked());
System.out.println("Held by me: " + lock.isHeldByCurrentThread());
boolean locked = lock.tryLock();
System.out.println("Lock acquired: " + locked);
});
ConcurrentUtils.stop(executor);
}
代码示例来源:origin: apache/cloudstack
@Override
public void syncClass(Class<?> cls) {
s_logger.debug("syncClass: " + cls.getName());
try {
s_logger.debug("sync start: " + DBSyncGeneric.getClassName(cls));
_lockSyncMode.lock();
_dbSync.setSyncMode(DBSyncGeneric.SYNC_MODE_UPDATE);
_dbSync.sync(cls);
_lockSyncMode.unlock();
s_logger.debug("sync finish: " + DBSyncGeneric.getClassName(cls));
} catch (Exception ex) {
s_logger.warn("Sync error: " + cls.getName(), ex);
if (_lockSyncMode.isLocked()) {
_lockSyncMode.unlock();
}
}
}
代码示例来源:origin: apache/cloudstack
s_logger.warn("DB Synchronization", ex);
syncState = SYNC_STATE_UNKNOWN;
if (_lockSyncMode.isLocked()) {
_lockSyncMode.unlock();
内容来源于网络,如有侵权,请联系作者删除!