public void waitForWaiters(long id, int numWaiters) throws InterruptedException {
    for (Entry entry;;) {
      entry = map.get(id);
      if (entry != null) {
        synchronized (entry) {
          if (entry.numWaiters >= numWaiters) {
            return;
          }
        }
      }
      Thread.sleep(100);
    }
  }
Test whether the given id is already locked by the current thread.
hbase-common/src/main/java/org/apache/hadoop/hbase/util/IdLock.java