public void waitForWaiters(T id, int numWaiters) throws InterruptedException {
    for (ReentrantReadWriteLock readWriteLock;;) {
      readWriteLock = getLock(id);
      if (readWriteLock != null) {
        synchronized (readWriteLock) {
          if (readWriteLock.getQueueLength() >= numWaiters) {
            return;
          }
        }
      }
      Thread.sleep(50);
    }
  }
Allows multiple concurrent clients to lock on a numeric id with ReentrantReadWriteLock. The
intended usage for read lock is as follows:

<pre>
ReentrantReadWriteLock lock = idReadWriteLock.getLock(id);
try {
  lock.readLock().lock();
  // User code.
} finally {
  lock.readLock().unlock();
}
</pre>

For write lock, use lock.writeLock()
hbase-server/src/main/java/org/apache/hadoop/hbase/util/IdReadWriteLock.java