code: public boolean waitUntil(BooleanSupplier predicate, long timeout, TimeUnit unit) throws InterruptedException
      {
          if (predicate.getAsBoolean())
          {
              return true;
          }
          long deadline = timeout > 0 ? System.currentTimeMillis() + unit.toMillis(timeout) : Long.MAX_VALUE;
          waiters.add(Thread.currentThread());
          try
          {
              while (true)
              {
                  LockSupport.parkUntil(blocker, deadline);
                  if (Thread.interrupted())
                  {
                      throw new InterruptedException();
                  }
                  if (predicate.getAsBoolean())
                  {
                      return true;
                  }
                  if (deadline <= System.currentTimeMillis())
                  {
                      return false;
                  }
              }
          }
          finally
          {
              boolean removed = waiters.remove(Thread.currentThread());
              assert removed;
          }
      }
docs: Waits until predicate is true or after timeout.
  <p>
  If predicate is true returns immediately true.
  <p>
  If timeout passed returns false
  <p>
  If thread is interrupted throws InterruptedException
  @param predicate
  @param timeout
  @param unit
  @return
  @throws InterruptedException