code: private static synchronized AsyncTimeout awaitTimeout() throws InterruptedException {
      // Get the next eligible node.
      AsyncTimeout node = head.next;
  
      // The queue is empty. Wait for something to be enqueued.
      if (node == null) {
        AsyncTimeout.class.wait();
        return null;
      }
  
      long waitNanos = node.remainingNanos(System.nanoTime());
  
      // The head of the queue hasn't timed out yet. Await that.
      if (waitNanos > 0) {
        // Waiting is made complicated by the fact that we work in nanoseconds,
        // but the API wants (millis, nanos) in two arguments.
        long waitMillis = waitNanos / 1000000L;
        waitNanos -= (waitMillis * 1000000L);
        AsyncTimeout.class.wait(waitMillis, (int) waitNanos);
        return null;
      }
  
      // The head of the queue has timed out. Remove it.
      head.next = node.next;
      node.next = null;
      return node;
    }
docs: Removes and returns the node at the head of the list, waiting for it to
  time out if necessary. Returns null if the situation changes while waiting:
  either a newer node is inserted at the head, or the node being waited on
  has been removed.