private boolean waitForThreadState(Thread thread, Thread.State state) {
    long checkStartTimeMs = SystemTime.getInstance().milliseconds();
    while (thread.getState() != state) {
      if (SystemTime.getInstance().milliseconds() - checkStartTimeMs > MAX_WAIT_MS) {
        return false;
      } else {
        Thread.yield();
      }
    }
    return true;
  }
Wait for the given thread to reach the given thread state.
@param thread the thread whose state needs to be checked.
@param state the state that needs to be reached.
@return true if the state is reached within a predetermined timeout, false on timing out.
ambry-router/src/test/java/com/github/ambry/router/PutManagerTest.java