public class SimpleLock extends ReentrantLock
ReentrantLock that allows for easy usage
with Java 8 :) See locked(Runnable) and locked(Runnable)
method. Also methods for suppliers are available.| Constructor and Description |
|---|
SimpleLock()
Default constructor creating a default
ReentrantLock |
SimpleLock(boolean bFair)
Constructor creating a
ReentrantLock with the provided fairness |
| Modifier and Type | Method and Description |
|---|---|
boolean |
locked(BooleanSupplier aSupplier)
Execute the provided callable in a read lock.
|
double |
locked(DoubleSupplier aSupplier)
Execute the provided callable in a read lock.
|
int |
locked(IntSupplier aSupplier)
Execute the provided callable in a read lock.
|
long |
locked(LongSupplier aSupplier)
Execute the provided callable in a read lock.
|
void |
locked(Runnable aRunnable)
Execute the provided runnable in a read lock.
|
<T> T |
locked(Supplier<? extends T> aSupplier)
Execute the provided callable in a read lock.
|
<EXTYPE extends Exception> |
lockedThrowing(IThrowingRunnable<EXTYPE> aRunnable)
Execute the provided runnable in a read lock.
|
<T,EXTYPE extends Exception> |
lockedThrowing(IThrowingSupplier<? extends T,EXTYPE> aCallable)
Execute the provided callable in a read lock.
|
getHoldCount, getOwner, getQueuedThreads, getQueueLength, getWaitingThreads, getWaitQueueLength, hasQueuedThread, hasQueuedThreads, hasWaiters, isFair, isHeldByCurrentThread, isLocked, lock, lockInterruptibly, newCondition, toString, tryLock, tryLock, unlockpublic SimpleLock()
ReentrantLockpublic SimpleLock(boolean bFair)
ReentrantLock with the provided fairnessbFair - true if this lock should use a fair ordering policypublic void locked(@Nonnull Runnable aRunnable)
aRunnable - Runnable to be executed. May not be null.public <EXTYPE extends Exception> void lockedThrowing(@Nonnull IThrowingRunnable<EXTYPE> aRunnable) throws EXTYPE extends Exception
EXTYPE - Exception type to be thrownaRunnable - Runnable to be executed. May not be null.EXTYPE - If the callable throws the exceptionEXTYPE extends Exceptionpublic <T> T locked(@Nonnull Supplier<? extends T> aSupplier)
T - Return typeaSupplier - Callable to be executed. May not be null.null.public <T,EXTYPE extends Exception> T lockedThrowing(@Nonnull IThrowingSupplier<? extends T,EXTYPE> aCallable) throws EXTYPE extends Exception
T - Return typeEXTYPE - Exception type to be thrownaCallable - Callable to be executed. May not be null.null.EXTYPE - If the callable throws the exceptionEXTYPE extends Exceptionpublic boolean locked(@Nonnull BooleanSupplier aSupplier)
aSupplier - Callable to be executed. May not be null.null.public double locked(@Nonnull DoubleSupplier aSupplier)
aSupplier - Callable to be executed. May not be null.null.public int locked(@Nonnull IntSupplier aSupplier)
aSupplier - Callable to be executed. May not be null.null.public long locked(@Nonnull LongSupplier aSupplier)
aSupplier - Callable to be executed. May not be null.null.Copyright © 2014–2017 Philip Helger. All rights reserved.