Lock.
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv abstract Lock | |
| public void | |
| public void | lockInterruptibly()
Implements java. |
| public Condition | newCondition()
Implements java. Condition instance that is bound to this
Lock instance.
|
| public boolean | tryLock()
Implements java. |
| public boolean | tryLock(long
the maximum time to wait for the lock time, TimeUnit the time unit of the unit)time argumentImplements java. |
| public void |
| ForwardingLock | back to summary |
|---|---|
| pack-priv ForwardingLock() | |
| delegate | back to summary |
|---|---|
| pack-priv abstract Lock delegate() | |
| lock | back to summary |
|---|---|
| public void lock() Implements java. Doc from java. Acquires the lock. If the lock is not available then the current thread becomes disabled for thread scheduling purposes and lies dormant until the lock has been acquired. Implementation Considerations A
| |
| lockInterruptibly | back to summary |
|---|---|
| public void lockInterruptibly() throws InterruptedException Implements java. Doc from java. Acquires the lock unless the current thread is interrupted. Acquires the lock if it is available and returns immediately. If the lock is not available then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of two things happens:
If the current thread:
InterruptedException is thrown and the current thread's
interrupted status is cleared.
Implementation Considerations The ability to interrupt a lock acquisition in some implementations may not be possible, and if possible may be an expensive operation. The programmer should be aware that this may be the case. An implementation should document when this is the case. An implementation can favor responding to an interrupt over normal method return. A
| |
| newCondition | back to summary |
|---|---|
| public Condition newCondition() Implements java. Doc from java. Returns a new Before waiting on the condition the lock must be held by the
current thread.
A call to Implementation Considerations The exact operation of the | |
| tryLock | back to summary |
|---|---|
| public boolean tryLock() Implements java. Doc from java. Acquires the lock only if it is free at the time of invocation. Acquires the lock if it is available and returns immediately
with the value A typical usage idiom for this method would be:
This usage ensures that the lock is unlocked if it was acquired, and
doesn't try to unlock if the lock was not acquired.
| |
| tryLock | back to summary |
|---|---|
| public boolean tryLock(long time, TimeUnit unit) throws InterruptedException Implements java. Doc from java. Acquires the lock if it is free within the given waiting time and the current thread has not been interrupted. If the lock is available this method returns immediately
with the value
If the lock is acquired then the value If the current thread:
InterruptedException is thrown and the current thread's
interrupted status is cleared.
If the specified waiting time elapses then the value Implementation Considerations The ability to interrupt a lock acquisition in some implementations may not be possible, and if possible may be an expensive operation. The programmer should be aware that this may be the case. An implementation should document when this is the case. An implementation can favor responding to an interrupt over normal method return, or reporting a timeout. A
| |
| unlock | back to summary |
|---|---|
| public void unlock() Implements java. Doc from java. Releases the lock. Implementation Considerations A
| |