public class BinaryLock extends Object
BinaryLock can be used to prevent concurrent access to
the same resource, so, in essence, this is a very simplified Lock implementation, however lacking
many advanced capabilities.
A BinaryLock knows only two states, locked and unlocked. Attempts by the lock-holder to lock a
BinaryLock when locked or to unlock it when unlocked, will have no effect.
| Constructor and Description |
|---|
BinaryLock() |
public boolean lock()
Thread is holding the
lock and then return true to
indicate the successful lock acquisition, or return false,
if the calling Thread was interrupted while waiting for the lock.
If the caller is already holding the lock, the method will immediately return true without
any changes.
true if and only if the lock has been acquiredpublic void unlock()
Copyright © 2012 University of Konstanz, Distributed Systems Group. All Rights Reserved.