|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbb.util.TimeElapsedLatch
public class TimeElapsedLatch
This class provides a simple latch that is set once a specified amount of time has elapsed.
The amount of time that must elapse is supplied to the constructor,
and the latched
method may be queried to determine if this time has elapsed.
The original motivation for this class was for polling applications where the polling should only be tried for a maximum amount of time before it is considered to have failed.
Warning: this class may not operate properly if some external process resets the system clock.
This class is multithread safe: it is immutable (both its immediate state, as well as the deep state of its fields).
Field Summary | |
---|---|
private long |
timeElapsedTillLatch
|
private long |
timeStarted
|
Constructor Summary | |
---|---|
TimeElapsedLatch(long timeElapsedTillLatch)
Constructor. |
Method Summary | |
---|---|
boolean |
latched()
Returns true once the specified amount of time has elapsed, false until then. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final long timeStarted
private final long timeElapsedTillLatch
Constructor Detail |
---|
public TimeElapsedLatch(long timeElapsedTillLatch) throws IllegalArgumentException
timeElapsedTillLatch
- the amount of time (in milliseconds) that must elapse till this instance will latch
IllegalArgumentException
- if timeElapsedTillLatch < 0Method Detail |
---|
public boolean latched()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |