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.限定符和类型 | 字段和说明 |
---|---|
protected java.util.concurrent.atomic.AtomicReference<java.lang.Thread> |
holder |
protected java.lang.String |
name |
构造器和说明 |
---|
LockService.LockImpl(java.lang.String name) |
限定符和类型 | 方法和说明 |
---|---|
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
在接口中 java.util.concurrent.locks.Lock
public void lockInterruptibly() throws java.lang.InterruptedException
lockInterruptibly
在接口中 java.util.concurrent.locks.Lock
java.lang.InterruptedException
public boolean tryLock()
tryLock
在接口中 java.util.concurrent.locks.Lock
public boolean tryLock(long time, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
tryLock
在接口中 java.util.concurrent.locks.Lock
time
- unit
- java.lang.InterruptedException
public void unlock()
unlock
在接口中 java.util.concurrent.locks.Lock
public java.util.concurrent.locks.Condition newCondition()
newCondition
在接口中 java.util.concurrent.locks.Lock
public java.lang.String toString()
toString
在类中 java.lang.Object