Interface LockExecutor

All Known Implementing Classes:
LockExecutorImpl

@ClassVersion(sourceVersion="$Id: LockExecutor.java 1185 2026-04-06 10:26:47Z tquadrat $") @API(status=STABLE, since="0.1.0") public sealed interface LockExecutor permits LockExecutorImpl

Allows to execute an operation with an obtained lock.

Use this class like below:

…
final var lock = new ReentrantLock();
final var executor = LockExecutor.of( lock );
…
executor.execute( () -> doSomething() );
…
Note:
  • If your program is using AutoLock, you should use the corresponding methods from there.
Author:
Thomas Thrien (thomas.thrien@tquadrat.org)
Version:
$Id: LockExecutor.java 1185 2026-04-06 10:26:47Z tquadrat $
Since:
0.1.0
UML Diagram
UML Diagram for "org.tquadrat.foundation.lang.LockExecutor"

UML Diagram for "org.tquadrat.foundation.lang.LockExecutor"

UML Diagram for "org.tquadrat.foundation.lang.LockExecutor"
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    evaluate(Constraint constraint)
    Evaluates the given condition.
    default void
    execute(Action action)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Use perform(Action) instead; basically this method was renamed to avoid the unintended use of execute(Operation) when an Action should be used instead.
    <R> Optional<R>
    execute(Operation<R> operation)
    Executes the given operation.
    of(Lock lock)
    Creates a new LockExecutor from the given Lock instance.
    of(AutoLock lock)
    Creates a new LockExecutor from the given AutoLock instance.
    void
    perform(Action action)
    Performs the given action after obtaining the lock.