code: public int awaitAdvanceInterruptibly(int phase,
                                           long timeout, TimeUnit unit)
          throws InterruptedException, TimeoutException {
          long nanos = unit.toNanos(timeout);
          final Phaser root = this.root;
          long s = (root == this) ? state : reconcileState();
          int p = (int)(s >>> PHASE_SHIFT);
          if (phase < 0)
              return phase;
          if (p == phase) {
              QNode node = new QNode(this, phase, true, true, nanos);
              p = root.internalAwaitAdvance(phase, node);
              if (node.wasInterrupted)
                  throw new InterruptedException();
              else if (p == phase)
                  throw new TimeoutException();
          }
          return p;
      }
docs: Awaits the phase of this phaser to advance from the given phase
  value or the given timeout to elapse, throwing {@code
  InterruptedException} if interrupted while waiting, or
  returning immediately if the current phase is not equal to the
  given phase value or this phaser is terminated.
  
  @param phase an arrival phase number, or negative value if
  terminated; this argument is normally the value returned by a
  previous call to {@code arrive} or {@code arriveAndDeregister}.
  @param timeout how long to wait before giving up, in units of
  {@code unit}
  @param unit a {@code TimeUnit} determining how to interpret the
  {@code timeout} parameter
  @return the next arrival phase number, or the argument if it is
  negative, or the (negative) {@linkplain #getPhase() current phase}
  if terminated
  @throws InterruptedException if thread interrupted while waiting
  @throws TimeoutException if timed out while waiting