Awaits until the next work is ready (or the work queue is empty).

@throws InterruptedException
Whether the wait is interrupted.
422084
public void awaitNextReadyWork() throws InterruptedException {
	write.lockInterruptibly();
	try {
	    long next = getEarliestReadyEstimate();
	    while (!workAvailable() && !waitingWork.isEmpty()) {
		if (next > 0L) {
		    workChanged.awaitNanos(next - System.nanoTime()); // Or signal
		    next = getEarliestReadyEstimate(); // Might be new work added?
		}
	    }
	} finally {
	    write.unlock();
	}
    }
856826
public void await() {
        boolean intr = false;
        final Object lock = this.lock;
        try {
            synchronized (lock) {
                while (! readClosed) {
                    try {
                        lock.wait();
                    } catch (InterruptedException e) {
                        intr = true;
                    }
                }
            }
        } finally {
            if (intr) {
                Thread.currentThread().interrupt();
            }
        }
    }
426760
public static void prepare() throws InterruptedException {
		semaphore.acquire();
		if (cacheReference == masterCache) {
			slaveCache.clear();
		} else {
			masterCache.clear();
		}
	}
1153956
@SuppressWarnings("unchecked")
    // TODO: Consider removing this method as it is hardly ever useful.
    public synchronized <P extends Stanza> P nextResultBlockForever() throws InterruptedException {
        throwIfCancelled();

        while (true) {
            P res = (P) resultQueue.poll();
            if (res != null) {
                return res;
            }
            if (cancelled) {
                return null;
            }
            wait();
        }
    }
75789
public void run()
      throws IOException, InterruptedException {
    if (!this.workUnits.hasNext()) {
      log.warn("No work units to run in container " + containerIdOptional.or(""));
      return;
    }

    CountUpAndDownLatch countDownLatch = new CountUpAndDownLatch(0);
    this.tasks = runWorkUnits(countDownLatch);
    log.info("Waiting for submitted tasks of job {} to complete in container {}...", jobId,
        containerIdOptional.or(""));
    try {
      while (countDownLatch.getCount() > 0) {
        if (this.interruptionPredicate.test(this)) {
          log.info("Interrupting task execution due to satisfied predicate.");
          interruptTaskExecution(countDownLatch);
          break;
        }
        log.info(String.format("%d out of %d tasks of job %s are running in container %s", countDownLatch.getCount(),
            countDownLatch.getRegisteredParties(), jobId, containerIdOptional.or("")));
        if (countDownLatch.await(10, TimeUnit.SECONDS)) {
          break;
        }
      }
    } catch (InterruptedException interrupt) {
      log.info("Job interrupted by InterrupedException.");
      interruptTaskExecution(countDownLatch);
    }
    log.info("All assigned tasks of job {} have completed in container {}", jobId, containerIdOptional.or(""));
  }
1292986
int await() throws InterruptedException {
        int s = state.get();
        if (s == SUBMITTED || s == RUNNING && thread != Thread.currentThread()) {
            if (s == RUNNING || nsStartBy == nsAcceptBegin - 1) { // already started or no start timeout
                state.acquireSharedInterruptibly(1);
                s = state.get();
            } else { // wait for up to the start timeout, then continue waiting if task has started
                long nsGetBegin = System.nanoTime();
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                    Tr.debug(this, tc, "await start timeout for " + (nsStartBy - nsGetBegin) + "ns");
                state.tryAcquireSharedNanos(1, nsStartBy - nsGetBegin);
                s = state.get();
                if (s == SUBMITTED) { // attempt to abort the task
                    abort(true, new StartTimeoutException(getIdentifier(), getTaskName(), //
                                    System.nanoTime() - nsAcceptBegin, //
                                    nsStartBy - nsAcceptBegin));
                    s = state.get();
                }
                if (s == RUNNING) { // continue waiting
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                        Tr.debug(this, tc, "await completion");
                    state.acquireSharedInterruptibly(1);
                    s = state.get();
                }
            }
        }
        return s;
    }
805801
public void waitForData() throws InterruptedException {
        try {
            if (registryRemote == null) {
                waitForValue();
                return;
            }
            getRegistryRemote().waitForData();
        } catch (CouldNotPerformException ex) {
            ExceptionPrinter.printHistory("Could not wait until " + getName() + " is ready!", ex, logger);
        }
    }
46198
@SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter")
  private void waitForJobCompletion(final CommandSessionImpl session) throws InterruptedException {
    while (true) {
      Job job = session.foregroundJob();
      if (job == null) break;

      log.debug("Waiting for job completion: {}", job);
      synchronized (job) {
        if (job.status() == Job.Status.Foreground) {
          job.wait();
        }
      }
    }
  }
729864
private void waitUntilFlowPreparationFinish() throws InterruptedException {
    final Duration SLEEP_INTERVAL = Duration.ofSeconds(5);
    while (this.preparingFlowCount.intValue() != 0) {
      logger.info(this.preparingFlowCount + " flow(s) is/are still being setup before complete "
          + "deactivation.");
      Thread.sleep(SLEEP_INTERVAL.toMillis());
    }
  }
870407
public void await(long weight) throws InterruptedException {
        try {
            lock.lockInterruptibly();
            while (isPermit(weight) == false) {
                condition.await();
            }
        } finally {
            lock.unlock();
        }
    }
1217970
protected boolean waitForTasks() {
		synchronized (this.tasks) {
			while (!this.closed && !this.hasTaskPending()) {
				try {
					this.tasks.wait();
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		}

		return !this.closed;
	}
283764
public synchronized void waitForHandlers() throws InterruptedException {
    if (handlers != null) {
      for (int i = 0; i < handlerCount; i++) {
        if (handlers[i] != null) {
          handlers[i].join();
        }
      }
    }
  }
868251
protected void waitForServiceToBeUnbound() throws InterruptedException {
        Ln.d("Waiting for service to be unbound.");

        lockAcquireService.lock();
        try {
            while (spiceService != null) {
                conditionServiceUnbound.await();
            }
        } finally {
            lockAcquireService.unlock();
        }
    }
128350
private boolean waitForAdd(long waitStart, long maxWait) throws InterruptedException {
        while (this.size == 0) {
            if (!waitOnCondition(this.notEmpty, maxWait, waitStart)) {
                return false;
            }
        }

        return true;
    }
622492
public void await(Event event) throws InterruptedException {
        long timestamp = getTimestamp(event);
        try {
            lock.lockInterruptibly();
            single(timestamp);
            while (isPermit(event, timestamp) == false) {
                condition.await();
            }
        } finally {
            lock.unlock();
        }
    }
12959
public boolean waitFor() throws InterruptedException {
    try {
      // [START ]
      Job completedJob = job.waitFor();
      if (completedJob == null) {
        // job no longer exists
      } else if (completedJob.getStatus().getError() != null) {
        // job failed, handle error
      } else {
        // job completed successfully
      }
      // [END ]
    } catch (BigQueryException e) {
      // Timeouts shouldn't happen without a timeout option.
      if (e.getCause() instanceof PollException) {
        return false;
      }
      throw e;
    }
    return true;
  }
89326
public void await(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException {
        if (!latch.await(timeout, unit)) {
            throw new TimeoutException();
        }
    }