List of usage examples for java.util.concurrent.locks ReentrantReadWriteLock getQueueLength
public final int getQueueLength()
From source file:org.bremersee.objectlock.ObjectReadWriteLockImpl.java
@Override public void unlockReading(Object obj) { if (obj == null) { return;/*w w w .java2 s .com*/ } synchronized (locks) { ReentrantReadWriteLock l = locks.get(obj); if (l != null) { l.readLock().unlock(); if (l.getQueueLength() == 0) { l = locks.remove(obj); returnLock(l); } } } }
From source file:org.bremersee.objectlock.ObjectReadWriteLockImpl.java
@Override public void unlockWriting(Object obj) { if (obj == null) { return;/*from w ww . ja v a 2 s . c o m*/ } synchronized (locks) { ReentrantReadWriteLock l = locks.get(obj); if (l != null) { l.writeLock().unlock(); if (l.getQueueLength() == 0) { l = locks.remove(obj); returnLock(l); } } } }