@Mutable @ThreadSafe @GenerateBuilder @GenerateSubclass public abstract class NonReentrantLock extends net.digitalid.utility.rootclass.RootClass implements Lock, net.digitalid.utility.interfaces.Locking
PreconditionException if a thread tries to acquire a non-reentrant lock that it already holds.
It is highly recommended that you always follow a (successful) call to one of the lock methods immediately with a try-finally block like
lock.lock();
try {
// Do the synchronized operations here.
} finally {
lock.unlock();
}
| Constructor and Description |
|---|
NonReentrantLock() |
| Modifier and Type | Method and Description |
|---|---|
abstract @Nonnull ReentrantLock |
getReentrantLock()
Returns the fair reentrant lock which is used to implement this non-reentrant lock.
|
boolean |
isLockHeldByCurrentThread() |
void |
lock() |
void |
lockInterruptibly() |
@Nonnull Condition |
newCondition() |
boolean |
tryLock() |
boolean |
tryLock(long time,
@Nonnull TimeUnit unit) |
void |
unlock() |
equals, hashCode, initialize, toString@Pure @Derive(value="new ReentrantLock(true)") @Nonnull public abstract @Nonnull ReentrantLock getReentrantLock()
@Impure
@LockNotHeldByCurrentThread
public void lockInterruptibly()
throws InterruptedException
lockInterruptibly in interface LockInterruptedException@Impure @LockNotHeldByCurrentThread public boolean tryLock()
@Impure
@LockNotHeldByCurrentThread
public boolean tryLock(long time,
@Nonnull
@Nonnull TimeUnit unit)
throws InterruptedException
tryLock in interface LockInterruptedException@Impure @Nonnull public @Nonnull Condition newCondition()
newCondition in interface Lock@Pure public boolean isLockHeldByCurrentThread()
isLockHeldByCurrentThread in interface net.digitalid.utility.interfaces.LockingCopyright © 2017. All rights reserved.