public boolean waitUntilEmpty(long timeout) throws InterruptedException {
  if (!notifyLock.tryLock(timeout,TimeUnit.MILLISECONDS)) {
    return false;
  }
  try {
    return pending.isEmpty() || notifyCondition.await(timeout,TimeUnit.MILLISECONDS);
  }
  finally {
    notifyLock.unlock();
  }
}

public boolean waitUntilEmpty ( long timeout ) throws InterruptedException { if ( ! notifyLock . tryLock ( timeout , TimeUnit . MILLISECONDS ) ) { return false ; } try { return pending . isEmpty ( ) || notifyCondition . await ( timeout , TimeUnit . MILLISECONDS ) ; } finally { notifyLock . unlock ( ) ; } }
wait until the client ' s pending queue is empty . may not work if there are people concurrently adding to the queue
