|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjmri.util.WaitHandler
public class WaitHandler
Common utility class for handling the
"spurious wakeup from wait()"
problem described in the
Object.wait(long) JavaDocs
Generally, when waiting for a notify() operation,
you need to provide a test that a valid notify
had happened due to e.g. a state change, etc.
By default, interrupting the thread leaves the wait early with
the interrupted flag set. InterruptedException is not thrown.
You can modify this behavior via the handleInterruptedException routine.
new WaitHandler(this, 120) {
protected boolean wasSpurious() {
return !(state == expectedNextState);
}
};
| Constructor Summary | |
|---|---|
WaitHandler(Object self)
Wait forever, robustly handling "spurious wake" |
|
WaitHandler(Object self,
long interval)
Wait for a specified interval, robustly handling "spurious wake" |
|
| Method Summary | |
|---|---|
protected boolean |
wasSpurious()
Method to determine if a wake was spurious or not. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public WaitHandler(Object self,
long interval)
self - waiting Objectinterval - in millisecondspublic WaitHandler(Object self)
self - waiting Object| Method Detail |
|---|
protected boolean wasSpurious()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||