Interface LockExecutor

All Superinterfaces:
Executor
All Known Implementing Classes:
AbstractLockExecutor, FileLockExecutor

public interface LockExecutor extends Executor
An object that executes submitted Runnable or Callable tasks. Tasks are guaranteed to execute sequentially for the lock used when creating the executor instance.
Since:
3.5.0
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    Executes the given task, with the guarantee no other task for the same lock can run concurrently.
    <V> V
    execute(Callable<V> task)
    Executes the given task and returns its computed result, with the guarantee no other task for the same lock can run concurrently.
  • Method Details

    • execute

      default void execute(Runnable task)
      Executes the given task, with the guarantee no other task for the same lock can run concurrently.

      The task is expected to be very lightweight and short-running, so that it does't block for too long other concurrent requests.

      Specified by:
      execute in interface Executor
      Throws:
      CompletionException - if the task is either interrupted or the timeout to acquire the lock expires.
    • execute

      <V> V execute(Callable<V> task) throws Exception
      Executes the given task and returns its computed result, with the guarantee no other task for the same lock can run concurrently.

      The task is expected to be very lightweight and short-running, so that it does't block for too long other concurrent requests.

      Type Parameters:
      V - the result type of method call
      Parameters:
      task - the runnable task
      Returns:
      the computed result
      Throws:
      Exception - if unable to compute a result. The exception is a CompletionException if the task is either interrupted or the timeout to acquire the lock expires.