GraphLock { public void readUnlockAll() { final int nReadLocks = readWriteLock.getReadHoldCount(); for (int n = 0; n < nReadLocks; n++) { readLock.unlock(); } } GraphLock(); void readLock(); void readUnlock(); void readUnlockAll(); void writeLock(); void writeUnlock(); void checkHoldWriteLock();  }
@Test public void testReadUnlockAll() { GraphLock lock = new GraphLock(); lock.readLock(); lock.readLock(); Assert.assertEquals(lock.readWriteLock.getReadHoldCount(), 2); lock.readUnlockAll(); Assert.assertEquals(lock.readWriteLock.getReadLockCount(), 0); }