ReadWriteSharedLock extends ReentrantReadWriteLock { public int getWriteLockCount() { return writers.getReadLockCount(); }  int getReadHoldCount(); int getReadLockCount(); int getWriteHoldCount(); int getWriteLockCount(); boolean isWriteLockedByCurrentThread(); @Override ReadLock readLock(); @Override String toString(); @Override WriteLock writeLock();  }
@Test public void testGetWriteLockCount() { int count = TestData.getScaleCount(); final AtomicInteger finished = new AtomicInteger(0); Runnable runnable = new Runnable() { @Override public void run() { lock.writeLock().lock(); finished.incrementAndGet(); } }; for (int i = 0; i < count; i++) { new Thread(runnable).start(); } while (finished.get() < count) { continue; } Assert.assertEquals(lock.getWriteLockCount(), count); }