public class IdentifierBasedLock extends Object
Constructor and Description |
---|
IdentifierBasedLock()
Creates a new IdentifierBasedLock instance.
|
Modifier and Type | Method and Description |
---|---|
boolean |
hasLock(String identifier)
Indicates whether the current thread hold a lock for the given
identifier . |
void |
obtainLock(String identifier)
Obtain a lock on the given
identifier . |
void |
releaseLock(String identifier)
Release the lock held on the given
identifier . |
public IdentifierBasedLock()
public boolean hasLock(String identifier)
identifier
.identifier
- The identifier of the lock to verifytrue
if the current thread holds a lock, otherwise false
public void obtainLock(String identifier)
identifier
. This method will block until a lock was successfully
obtained.
Note: when an exception occurs during the locking process, the lock may or may not have been allocated.identifier
- the identifier of the lock to obtain.public void releaseLock(String identifier)
identifier
. If no valid lock is held by the current thread, an
exception is thrown.identifier
- the identifier to release the lock for.IllegalStateException
- if no lock was ever obtained for this aggregateIllegalMonitorStateException
- if a lock was obtained, but is not currently held by the current threadCopyright © 2010-2014. All Rights Reserved.