public class Latch extends Object
Park/unpark example: use open() to unpark and waitAndClose() to park.
AutoResetEvent example: use open() to set, close() to reset, and waitAndClose() to wait.
ManualResetEvent example: use open() to set, close() to reset, and wait() to wait.
Modifier and Type | Field and Description |
---|---|
private boolean |
open |
private Monitor |
schedLock |
Constructor and Description |
---|
Latch(boolean open)
Create a new latch, with the given open/closed state.
|
Modifier and Type | Method and Description |
---|---|
void |
closeWithHandshake()
Close the latch, causing future calls to wait() or waitAndClose()
to block.
|
void |
openNoHandshake()
Like open(), but does it without letting the system know that we
could potentially block.
|
void |
openWithHandshake()
Open the latch and let all of the thread(s) waiting on it through.
|
void |
waitAndCloseWithHandshake()
Wait for the latch to become open, and then close it and return.
|
void |
waitWithHandshake()
Wait for the latch to become open.
|
public Latch(boolean open)
open
- whether the latch is open or closed at
the beginningpublic void openWithHandshake()
public void openNoHandshake()
public void closeWithHandshake()
public void waitWithHandshake()
public void waitAndCloseWithHandshake()