|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface FinegrainedLock
Provides primitive lock operations for the granularity that was used to create an instance of this lock. At the
creation of a FinegrainedLock instance a default lock type is also store, which is corresponds to the default
lock type of the underlying data structure.
IMPORTANT: an instance of FinegrainedLock) is not supposed to be cached or stored in any field or data structure since the state of the underlying data structure can have changed in the meantime. Each time a locking operation is performed a new instance of {@code FinegrainedLock} needs to be obtained.
| Method Summary | |
|---|---|
boolean |
isHeldByCurrentThread()
Indicates whether the current thread is holding a lock that corresponds to this granularity and default lock type. |
boolean |
isHeldByCurrentThread(LockType lockType)
Indicates whether the current thread is holding a lock that corresponds to this granularity and specified lock type. |
void |
lock()
Lock the underlying data structure for this lock's granularity using the default lock type. |
void |
lock(LockType lockType)
Lock the underlying data structure for this lock's granularity with a specified lock type. |
boolean |
tryLock()
Lock the underlying data structure for this lock's granularity using the default lock type only if the lock is not held by another thread at the time of invocation. |
boolean |
tryLock(LockType lockType)
Lock the underlying data structure for this lock's granularity with a specified lock type only if the lock is not held by another thread at the time of invocation. |
boolean |
tryLock(LockType lockType,
long timeout,
TimeUnit unit)
Lock the underlying data structure for this lock's granularity with a specified lock type only if the lock is not held by another thread within a given time. |
boolean |
tryLock(long timeout,
TimeUnit unit)
Lock the underlying data structure for this lock's granularity using the default lock type only if the lock is not held by another thread within a given time. |
void |
unlock()
Unlocks the underlying data structure for this lock's granularity using the default lock type. |
void |
unlock(LockType lockType)
Unlocks the underlying data structure for this lock's granularity using the specified lock type. |
| Method Detail |
|---|
void lock()
void lock(LockType lockType)
lockType - the type of lock that needs to be lockedboolean tryLock()
true if the lock was successfully acquired; or {@code false) otherwiseboolean tryLock(LockType lockType)
lockType - the type of lock that needs to be locked
true if the lock was successfully acquired; or {@code false) otherwise
boolean tryLock(long timeout,
TimeUnit unit)
throws InterruptedException
timeout - the time to waitunit - the time unit of the timeout argument
true if the lock was successfully acquired; or {@code false) otherwise
InterruptedException
boolean tryLock(LockType lockType,
long timeout,
TimeUnit unit)
throws InterruptedException
lockType - the type of lock that needs to be lockedtimeout - the time to waitunit - the time unit of the timeout argument
true if the lock was successfully acquired; or {@code false) otherwise
InterruptedExceptionvoid unlock()
void unlock(LockType lockType)
lockType - the type of lock that needs to be unlockedboolean isHeldByCurrentThread()
true if the current thread is holding the lock; or false otherwiseboolean isHeldByCurrentThread(LockType lockType)
lockType - the type of lock that needs to be checked
true if the current thread is holding the lock; or false otherwise
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||