java.util.concurrent.locks.ReentrantReadWriteLock#getReadLockCount()源码实例Demo

下面列出了java.util.concurrent.locks.ReentrantReadWriteLock#getReadLockCount() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: linstor-server   文件: CmdDisplayLockStatus.java
private void reportRwLock(PrintStream output, String label, ReadWriteLock readWriteLock)
{
    ReentrantReadWriteLock reentrantReadWriteLock = (ReentrantReadWriteLock) readWriteLock;

    boolean writeLocked = reentrantReadWriteLock.isWriteLocked();
    boolean fair = reentrantReadWriteLock.isFair();
    boolean queued = reentrantReadWriteLock.hasQueuedThreads();
    int readerCount = reentrantReadWriteLock.getReadLockCount();

    output.printf(
        RWLOCK_FORMAT,
        label,
        writeLocked ? "Y" : "N",
        fair ? "Y" : "N",
        queued ? "Y" : "N",
        readerCount
    );
}
 
源代码2 项目: data-prep   文件: ReentrantReadWriteLockGroup.java
/**
 * Returns <tt>true</tt> if the specified lock is held by a thread or is asked (some threads are blocking and
 * waiting to acquire the lock) and <tt>otherwise</tt>.
 * 
 * @param lock the specified lock
 * @return <tt>true</tt> if the specified lock is held by a thread or is asked (some threads are blocking and
 * waiting to acquire the lock) and <tt>otherwise</tt>.
 */
private boolean lockHeldOrAsked(ReentrantReadWriteLock lock) {
    if (lock.hasQueuedThreads() || lock.getReadLockCount() > 0 || lock.isWriteLocked()) {
        return true;
    }
    return false;
}