/**
  * Waits for pendingCount to shrink to a given limit size.
  *
  * <p>WARNING: Pay attention when using this feature so that executors don't have circular task
  * dependencies. If they depend on each others pendingCount, this may cause a deadlock!
  */
 public void awaitPendingCount(final long limit) throws InterruptedException {
   pendingCountLock.lock();
   try {
     final Condition condition = pendingCount_limitListener.get(limit);
     while (getPendingCount() > limit) {
       Threads.throwIfInterrupted();
       condition.await();
     }
   } finally {
     pendingCountLock.unlock();
   }
 }