public class TimeOut extends Object
Constructor and Description |
---|
TimeOut(long interval,
TimeUnit unit,
TimeSource timeSource) |
Modifier and Type | Method and Description |
---|---|
boolean |
hasTimedOut() |
void |
sleep(long ms) |
long |
timeElapsed(TimeUnit unit) |
long |
timeLeft(TimeUnit unit) |
void |
waitFor(String messageOnTimeOut,
Supplier<Boolean> supplier)
Wait until the given
Supplier returns true or the time out expires which ever happens first |
public TimeOut(long interval, TimeUnit unit, TimeSource timeSource)
public boolean hasTimedOut()
public void sleep(long ms) throws InterruptedException
InterruptedException
public long timeLeft(TimeUnit unit)
public long timeElapsed(TimeUnit unit)
public void waitFor(String messageOnTimeOut, Supplier<Boolean> supplier) throws InterruptedException, TimeoutException
Supplier
returns true or the time out expires which ever happens firstmessageOnTimeOut
- the exception message to be used in case a TimeoutException is thrownsupplier
- a Supplier
that returns a Boolean
valueInterruptedException
- if any thread has interrupted the current threadTimeoutException
- if the timeout expiresCopyright © 2000-2018 Apache Software Foundation. All Rights Reserved.