public class Timeout
extends java.lang.Object
long timeout and a TimeUnit unit argument, pass:
timeout.nanosLeft(), TimeUnit.NANOSECONDS
| Constructor and Description |
|---|
Timeout(long timeout,
java.util.concurrent.TimeUnit unit)
Starts a new
Timeout that begins now and expires within the given timeout
from the instant this constructor has been called. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
isExpired()
Tests whether the timeout has expired.
|
long |
nanosLeft()
Returns how many nanoseconds are left before the timeout expires,
or a negative number indicating how many nanoseconds have elapsed since
the timeout expired.
|
long |
timeLeft(java.util.concurrent.TimeUnit unit)
Returns how long is left before the timeout expires in the given time unit.
|
public Timeout(long timeout,
java.util.concurrent.TimeUnit unit)
Timeout that begins now and expires within the given timeout
from the instant this constructor has been called.timeout - the duration of the timeoutunit - the timeout's time unitpublic long nanosLeft()
public long timeLeft(java.util.concurrent.TimeUnit unit)
unit - the time unit of the return valuepublic boolean isExpired()