public class Gate extends Object implements SyncInterface
lock() or unlock() to lock or unlock the Gate.
Whenever a thread calls enter it will be blocked until the Gate is unlocked by another thread.| Constructor and Description |
|---|
Gate()
Construct unlocked Gate.
|
Gate(boolean locked)
Construct gate.
|
| Modifier and Type | Method and Description |
|---|---|
void |
enter()
Enter the Gate.
|
boolean |
isLocked()
Check if the Gate is locked.
|
void |
lock()
Lock the Gate.
|
String |
toString() |
boolean |
tryLock()
Try to lock the Gate.
|
void |
unlock()
Unlock the Gate.
|
public Gate(boolean locked)
locked - true if the Gate should be initially lockedpublic Gate()
public void lock()
throws InterruptedException
lock in interface SyncInterfaceInterruptedExceptionpublic void unlock()
unlock in interface SyncInterfacepublic boolean tryLock()
throws InterruptedException
tryLock in interface SyncInterfacetrueInterruptedExceptionpublic boolean isLocked()
true if the Gate is locked.public void enter()
throws InterruptedException
InterruptedExceptionCopyright © 2014–2016 Tomas Teubner. All rights reserved.