public class BroadMultiLock extends Object implements MultiLock
MultiLock interface with broad locking feature which means a thread might block for an ID
even tough that ID is not locked by another thread but a different ID is locked. So this class guarantees that an ID
cannot be locked by multiple parties which ensures correctness but it might block threads more eagerly in order to
provide this guarantee. The benefit of this class is more efficient locking and unlocking| Modifier and Type | Field and Description |
|---|---|
static org.slf4j.Logger |
LOGGER |
| Constructor and Description |
|---|
BroadMultiLock() |
| Modifier and Type | Method and Description |
|---|---|
void |
lock(int lockID)
Locks the given ID, waiting indefinitely if another thread already has a lock.
|
boolean |
tryLock(int lockID)
Tries to lock the given ID if it is possible to do so immediately and return
true. |
void |
unlock(int lockID)
Unlocks the given ID.
|
public void lock(int lockID)
MultiLockpublic boolean tryLock(int lockID)
MultiLocktrue. If the lock is
already held by another thread, this function immediately returns false. Since this class does not
provide reentarant behavior, this function will return false even if it is the same thread that
holds the lock before this function call.public void unlock(int lockID)
throws IllegalArgumentException
MultiLockMultiLock.lock(int).unlock in interface MultiLockIllegalArgumentExceptionCopyright © 2010-2016 Stardog Union. All Rights Reserved.