public class Waiter extends Object
Object.wait()
/ Object.notify()
/
Object.notifyAll()
as the underlying implementation. This class
should be used when notifications about changes in the state that affects
the condition are possible.
This should be the preferred method over AsyncWaiter
and
Blocker
.
Constructor and Description |
---|
Waiter(Condition condition)
Creates a waiter.
|
Modifier and Type | Method and Description |
---|---|
void |
checkCondition()
Evaluates the condition and unlocks any locked thread if the condition
has been met (tells the waiting threads that something happened).
|
void |
waitForCondition()
Blocks the current thread until the condition is met.
|
public Waiter(Condition condition) throws NullPointerException
condition
- condition to wait forNullPointerException
- if condition
is null
public void waitForCondition()
checkCondition()
must be called when the state that affects
the condition changes so the condition is reevaluated and the threads
may be unlocked.public void checkCondition()
Copyright © 2016. All Rights Reserved.