@Deprecated public static void waitForCriterion(final WaitCriterion waitCriterion,final long timeoutMillis,final long pollingInterval,final boolean throwOnTimeout){
  long waitThisTime=jitterInterval(pollingInterval);
  final long tilt=System.currentTimeMillis() + timeoutMillis;
  for (; ; ) {
    if (waitCriterion.done()) {
      return;
    }
    if (waitCriterion instanceof StoppableWaitCriterion) {
      StoppableWaitCriterion ev2=(StoppableWaitCriterion)waitCriterion;
      if (ev2.stopWaiting()) {
        if (throwOnTimeout) {
          fail("stopWaiting returned true: " + waitCriterion.description());
        }
        return;
      }
    }
    long timeLeft=tilt - System.currentTimeMillis();
    if (timeLeft <= 0) {
      if (!throwOnTimeout) {
        return;
      }
      fail("Event never occurred after " + timeoutMillis + " ms: "+ waitCriterion.description());
    }
    if (waitThisTime > timeLeft) {
      waitThisTime=timeLeft;
    }
    Thread.yield();
    try {
      Thread.sleep(waitThisTime);
    }
 catch (    InterruptedException e) {
      fail("interrupted");
    }
  }
}

@ Deprecated public static void waitForCriterion ( final WaitCriterion waitCriterion , final long timeoutMillis , final long pollingInterval , final boolean throwOnTimeout ) { long waitThisTime = jitterInterval ( pollingInterval ) ; final long tilt = System . currentTimeMillis ( ) + timeoutMillis ; for ( ; ; ) { if ( waitCriterion . done ( ) ) { return ; } if ( waitCriterion instanceof StoppableWaitCriterion ) { StoppableWaitCriterion ev2 = ( StoppableWaitCriterion ) waitCriterion ; if ( ev2 . stopWaiting ( ) ) { if ( throwOnTimeout ) { fail ( "stopWaiting returned true: " + waitCriterion . description ( ) ) ; } return ; } } long timeLeft = tilt - System . currentTimeMillis ( ) ; if ( timeLeft <= 0 ) { if ( ! throwOnTimeout ) { return ; } fail ( "Event never occurred after " + timeoutMillis + " ms: " + waitCriterion . description ( ) ) ; } if ( waitThisTime > timeLeft ) { waitThisTime = timeLeft ; } Thread . yield ( ) ; try { Thread . sleep ( waitThisTime ) ; } catch ( InterruptedException e ) { fail ( "interrupted" ) ; } } }
wait until given criterion is met
