Example usage for java.util.concurrent.locks ReentrantReadWriteLock hashCode

List of usage examples for java.util.concurrent.locks ReentrantReadWriteLock hashCode

Introduction

In this page you can find the example usage for java.util.concurrent.locks ReentrantReadWriteLock hashCode.

Prototype

@HotSpotIntrinsicCandidate
public native int hashCode();

Source Link

Document

Returns a hash code value for the object.

Usage

From source file:Main.java

private static String getLockInfo(ReentrantReadWriteLock lock) {
    String lockid = "RWLock@" + Integer.toHexString(lock.hashCode());
    return lockid + " readLockCount=" + lock.getReadLockCount() + " isWriteLocked=" + lock.isWriteLocked();
}

From source file:io.hops.hopsworks.common.security.CertificateMaterializer.java

private TreeSet<ReentrantReadWriteLock> acquireWriteLocks(Map<MaterialKey, ReentrantReadWriteLock> lockSet) {
    TreeSet<ReentrantReadWriteLock> acquiredLocks = new TreeSet<>(new Comparator<ReentrantReadWriteLock>() {
        @Override/*from w ww.  jav  a  2s  . c om*/
        public int compare(ReentrantReadWriteLock t0, ReentrantReadWriteLock t1) {
            if (t0.hashCode() < t1.hashCode()) {
                return -1;
            } else if (t0.hashCode() > t1.hashCode()) {
                return 1;
            }
            return 0;
        }
    });

    lockSet.values().stream().forEach(l -> {
        l.writeLock().lock();
        acquiredLocks.add(l);
    });
    return acquiredLocks;
}