protected class LockService.LockImpl
extends java.lang.Object
implements java.util.concurrent.locks.Lock
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.Modifier and Type | Field and Description |
---|---|
protected java.util.concurrent.atomic.AtomicReference<java.lang.Thread> |
holder |
protected java.lang.String |
name |
Constructor and Description |
---|
LockImpl(java.lang.String name) |
Modifier and Type | Method and Description |
---|---|
void |
lock()
Blocks until the lock has been acquired.
|
void |
lockInterruptibly()
If the thread is interrupted at entry, the call will throw an InterruptedException immediately and the lock
won't be acquired.
|
java.util.concurrent.locks.Condition |
newCondition()
This condition object is only allowed to work 1 for each lock.
|
java.lang.String |
toString() |
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.
|
boolean |
tryLock(long time,
java.util.concurrent.TimeUnit unit)
* If the thread is interrupted at entry, the call will throw an InterruptedException immediately and the lock
won't be acquired.
|
void |
unlock()
Releases a lock.
|
protected final java.lang.String name
protected final java.util.concurrent.atomic.AtomicReference<java.lang.Thread> holder
public void lock()
lock
in interface java.util.concurrent.locks.Lock
public void lockInterruptibly() throws java.lang.InterruptedException
lockInterruptibly
in interface java.util.concurrent.locks.Lock
java.lang.InterruptedException
public boolean tryLock()
tryLock
in interface java.util.concurrent.locks.Lock
public boolean tryLock(long time, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
tryLock
in interface java.util.concurrent.locks.Lock
time
- unit
- java.lang.InterruptedException
public void unlock()
unlock
in interface java.util.concurrent.locks.Lock
public java.util.concurrent.locks.Condition newCondition()
newCondition
in interface java.util.concurrent.locks.Lock
public java.lang.String toString()
toString
in class java.lang.Object
Copyright © 1998-2020 Red Hat. All Rights Reserved.