Interface LockExecutor
- All Superinterfaces:
Executor
- All Known Implementing Classes:
AbstractLockExecutor,FileLockExecutor
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 TypeMethodDescriptiondefault voidExecutes the given task, with the guarantee no other task for the same lock can run concurrently.<V> VExecutes the given task and returns its computed result, with the guarantee no other task for the same lock can run concurrently.
-
Method Details
-
execute
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:
executein interfaceExecutor- Throws:
CompletionException- if thetaskis eitherinterruptedor the timeout to acquire the lock expires.
-
execute
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 methodcall- Parameters:
task- the runnable task- Returns:
- the computed result
- Throws:
Exception- if unable to compute a result. The exception is aCompletionExceptionif thetaskis eitherinterruptedor the timeout to acquire the lock expires.
-