Package org.jgroups.blocks.locking
Class LockService.LockImpl
java.lang.Object
org.jgroups.blocks.locking.LockService.LockImpl
- All Implemented Interfaces:
Lock
- Enclosing class:
LockService
Implementation of
Lock. This is a client stub communicates with a server equivalent. The semantics are
more or less those of Lock, but may differ slightly.There is no reference counting of lock owners, so acquisition of a lock already held by a thread is a no-op. Also, releasing the lock after it was already released is a no-op as well.
An exact description is provided below.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidlock()Blocks until the lock has been acquired.voidIf the thread is interrupted at entry, the call will throw an InterruptedException immediately and the lock won't be acquired.This condition object is only allowed to work 1 for each lock.toString()booleantryLock()If the thread is interrupted at entry or during the call, no InterruptedException will be thrown, but the thread's status will be set to interrupted upon return.boolean* If the thread is interrupted at entry, the call will throw an InterruptedException immediately and the lock won't be acquired.voidunlock()Releases a lock.
-
Field Details
-
name
-
holder
-
-
Constructor Details
-
LockImpl
-
-
Method Details
-
lock
public void lock()Blocks until the lock has been acquired. Masks interrupts; if an interrupt was received on entry or while waiting for the lock acquisition, it won't cause the call to return. However, the thread's status will be set to interrupted when the call returns. -
lockInterruptibly
If the thread is interrupted at entry, the call will throw an InterruptedException immediately and the lock won't be acquired. If the thread is interrupted while waiting for the lock acquition, an InterruptedException will also be thrown immediately. The thread's interrupt status will not be set after the call returns.- Specified by:
lockInterruptiblyin interfaceLock- Throws:
InterruptedException
-
tryLock
public boolean tryLock()If the thread is interrupted at entry or during the call, no InterruptedException will be thrown, but the thread's status will be set to interrupted upon return. An interrupt has therefore no impact on the return value (success or failure). -
tryLock
* If the thread is interrupted at entry, the call will throw an InterruptedException immediately and the lock won't be acquired. If the thread is interrupted while waiting for the lock acquition, an InterruptedException will also be thrown immediately. The thread's interrupt status will not be set after the call returns.- Specified by:
tryLockin interfaceLock- Parameters:
time-unit-- Returns:
- Throws:
InterruptedException
-
unlock
public void unlock()Releases a lock. Contrary to the parent's implementation, this method can be called more than once: the release of a lock that has already been released, or is not owned by this thread is a no-op. -
newCondition
This condition object is only allowed to work 1 for each lock. If more than 1 condition is created for this lock, they both will be awaiting/signalling on the same lock- Specified by:
newConditionin interfaceLock
-
toString
-