public class TimeOut extends Object
Modifier and Type | Field and Description |
---|---|
static TimeOut |
Forever |
static TimeOut |
Immediate |
static long |
Infinite
This is the value for an infinite timeout in milliseconds, equal to -1.
|
protected long |
interval |
protected long |
nanos |
protected long |
started |
static long |
Zero
This is the value for a zero timeout in milliseconds, equal to 0.
|
Constructor and Description |
---|
TimeOut(long time)
Create a timeout with the specified number of milliseconds.
|
Modifier and Type | Method and Description |
---|---|
long |
elapsed()
How many milliseconds has elapsed since the TimeOut was started/reset.
|
void |
expire()
Force it to expire.
|
long |
getInterval()
Gets the interval in milliseconds of this TimeOut.
|
TimeOut |
getNew()
Get a copy of this TimeOut, i.e. one which has the same interval.
|
boolean |
hasExpired()
Has this TimeOut expired yet?
|
static long |
now() |
long |
remaining()
How many milliseconds remaining?
|
TimeOut |
reset()
Reset the TimeOut so that it will time out again after its interval.
|
void |
waitOn(Object obj)
Call the wait() method on the specified object with the amount of time
that is left.
|
public static final long Infinite
public static final long Zero
protected long started
protected long interval
protected long nanos
public static TimeOut Forever
public static TimeOut Immediate
public TimeOut(long time)
public static final long now()
public long getInterval()
public TimeOut reset()
public boolean hasExpired()
public long remaining()
public long elapsed()
public void expire()
public TimeOut getNew()
public final void waitOn(Object obj) throws InterruptedException
obj
- the object to call wait() on.InterruptedException
- if it was interrupted.