コード例 #1
0
 private void notifyPendingCountListeners(final Long currentPendingCount) {
   pendingCountLock.lock();
   try {
     for (final Long limit : pendingCount_limitListener.keySet()) {
       if (currentPendingCount <= limit) {
         final Condition condition = pendingCount_limitListener.get(limit);
         if (condition != null) {
           condition.signalAll();
         }
       }
     }
   } finally {
     pendingCountLock.unlock();
   }
 }
コード例 #2
0
 /**
  * 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();
   }
 }