public class UpdateLock extends Object implements InterProcessLock
Constructor and Description |
---|
UpdateLock() |
Modifier and Type | Method and Description |
---|---|
boolean |
isHeld()
Returns if this lock is held by any thread.
|
boolean |
isHeldByCurrentThread()
Checks if this lock is held by current thread.
|
void |
lock()
Acquires the lock.
|
void |
lockInterruptibly()
Acquires the lock unless the current thread is interrupted.
|
boolean |
tryLock()
Acquires the lock only if it is free at the time of invocation, also if the lock is already
held by the current thread, this call immediately returns
true . |
boolean |
tryLock(long time,
TimeUnit unit) |
void |
unlock()
Releases the lock (and all stronger-level lock, in the context of
InterProcessReadWriteUpdateLock , if the lock is not held by the current thread, returns
immediately. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
newCondition
public boolean isHeldByCurrentThread()
InterProcessLock
isHeldByCurrentThread
in interface InterProcessLock
public void lock()
InterProcessLock
InterProcessReadWriteUpdateLock
) is already held by the current thread, this call returns
immediately.
If the lock is not available then the current thread enters a busy loop. After some
threshold time spent in a busy loop, the thread might be disabled for thread
scheduling purposes and lay dormant until the lock has been acquired. After some
implementation-defined time spent in waiting for the lock acquisition,
InterProcessDeadLockException
is thrown.
lock
in interface Lock
lock
in interface InterProcessLock
public void lockInterruptibly() throws InterruptedException
InterProcessLock
InterProcessReadWriteUpdateLock
) is already held by the current thread,
this call returns immediately.
If the lock is not available then the current thread enters a busy loop, and after some threshold time spend in a busy loop, the thread might be disabled for thread scheduling purposes and lay dormant until one of three things happens:
lockInterruptibly()
successfully
returns.
InterruptedException
is thrown and the current thread's interrupted status is
cleared.
InterProcessDeadLockException
is thrown.
lockInterruptibly
in interface Lock
lockInterruptibly
in interface InterProcessLock
InterruptedException
- if the current thread is interrupted while acquiring the lockpublic boolean tryLock()
InterProcessLock
true
.
Acquires the lock if it is available and returns immediately
with the value true
.
If the lock is not available then this method will return
immediately with the value false
.
tryLock
in interface Lock
tryLock
in interface InterProcessLock
true
if the lock was acquired and false
otherwisepublic boolean tryLock(long time, @NotNull TimeUnit unit) throws InterruptedException
tryLock
in interface Lock
InterruptedException
public void unlock()
InterProcessLock
InterProcessReadWriteUpdateLock
, if the lock is not held by the current thread, returns
immediately.unlock
in interface Lock
unlock
in interface InterProcessLock
public boolean isHeld()
InterProcessLock
isHeld
in interface InterProcessLock
Copyright © 2022. All rights reserved.