org.linkedin.util-core/src/main/java/org/linkedin/util/concurrent/ConcurrentUtils.java
public static void awaitUntil(Clock clock, Condition condition, long endTime)
    throws InterruptedException, TimeoutException
  {
    if(endTime <= 0)
      condition.await();
    else
    {
      long now = clock.currentTimeMillis();
      if(now >= endTime)
        throw new TimeoutException("timeout reached while waiting on the lock: "
                                   + condition);

      if(!condition.await(endTime - now, TimeUnit.MILLISECONDS))
        throw new TimeoutException("timeout reached while waiting on the lock: "
                                   + condition);
    }
  }
public static void awaitUntil(Clock clock, Condition condition, long endTime)
    throws InterruptedException, TimeoutException
  {
    if(endTime <= 0)
      condition.await();
    else
    {
      long now = clock.currentTimeMillis();
      if(now >= endTime)
        throw new TimeoutException("timeout reached while waiting on the lock: "
                                   + condition);

      if(!condition.await(endTime - now, TimeUnit.MILLISECONDS))
        throw new TimeoutException("timeout reached while waiting on the lock: "
                                   + condition);
    }
  }
public static void awaitUntil ( Clock clock , Condition condition , long endTime ) throws InterruptedException , TimeoutException { if ( endTime <= 0 ) condition . await ( ) ; else { long now = clock . currentTimeMillis ( ) ; if ( now >= endTime ) throw new TimeoutException ( "timeout reached while waiting on the lock: " + condition ) ; if ( ! condition . await ( endTime - now , TimeUnit . MILLISECONDS ) ) throw new TimeoutException ( "timeout reached while waiting on the lock: " + condition ) ; } }
Waits on the condition but if end time is expired then throws an
exception. On purpose this method does not synchronize on the lock
because it must be called from a block which synchronizes on it

@param condition the condition to wait on
@param endTime the time after which an exception is thrown (compared
to {@link java.lang.System#currentTimeMillis()}. If &lt; 0 then wait
indefinitely (so <code>TimeOutException</code> will not be thrown!)
@throws InterruptedException if the thread is interrupted while waiting
@throws TimeoutException if the time has been reached
Waits on the condition but if end time is expired then throws an exception . On purpose this method does not synchronize on the lock because it must be called from a block which synchronizes on it