code: public void wait(String message, long timeoutInMilliseconds, long intervalInMilliseconds) {
      long start = System.currentTimeMillis();
      long end = start + timeoutInMilliseconds;
      while (System.currentTimeMillis() < end) {
        if (until()) return;
        try {
          Thread.sleep(intervalInMilliseconds);
        } catch (InterruptedException e) {
          throw new RuntimeException(e);
        }
      }
      throw new WaitTimedOutException(message);
    }
docs: Wait until the "until" condition returns true or time runs out.
  
  @param message the failure message
  @param timeoutInMilliseconds the amount of time to wait before giving up
  @param intervalInMilliseconds the interval to pause between checking "until"
  @throws WaitTimedOutException if "until" doesn't return true until the timeout
  @see #until()