}
}
// If the state requires it then wait until the state changes.
if (state.mustWait()) {
Countdown countdown = Countdown.getCountdown(timeout, clock);
do {
try {
Period remaining = countdown.countdown();
entry.wait(remaining.inMillisTreatIndefinitelyAsZero());
state = entry.getState();
} catch (InterruptedException e) {
throw new ExtendedRuntimeException(e);
} catch (TimedOutException e) {