public interface Executor
Executor
implementations are expected to run long running (blocking) tasks which may depend on other tasks
submitted to the same Executor
instance.
In order to avoid deadlocks, it is generally a good idea to not allow task queuing in the Executor
.Modifier and Type | Method and Description |
---|---|
Cancellable |
execute(java.lang.Runnable task)
Executes the passed
task as soon as possible. |
default Cancellable |
schedule(java.lang.Runnable task,
java.time.Duration delay)
Executes the passed
task after delay amount time has passed. |
Cancellable |
schedule(java.lang.Runnable task,
long delay,
java.util.concurrent.TimeUnit unit)
Executes the passed
task after delay amount of unit s time has passed. |
Cancellable execute(java.lang.Runnable task) throws java.util.concurrent.RejectedExecutionException
task
as soon as possible.task
- to execute.Cancellable
to cancel the task if not yet executed.java.util.concurrent.RejectedExecutionException
- If the task is rejected.Cancellable schedule(java.lang.Runnable task, long delay, java.util.concurrent.TimeUnit unit) throws java.util.concurrent.RejectedExecutionException
task
after delay
amount of unit
s time has passed.
Note this method is not guaranteed to provide real time execution. For example implementations are free to consolidate tasks into time buckets to reduce the overhead of timer management at the cost of reduced timer fidelity.
task
- to execute.delay
- The time duration that is allowed to elapse before task
is executed.unit
- The units for delay
.Cancellable
to cancel the task if not yet executed.java.util.concurrent.RejectedExecutionException
- If the task is rejected.default Cancellable schedule(java.lang.Runnable task, java.time.Duration delay) throws java.util.concurrent.RejectedExecutionException
task
after delay
amount time has passed.
Note this method is not guaranteed to provide real time execution. For example implementations are free to consolidate tasks into time buckets to reduce the overhead of timer management at the cost of reduced timer fidelity.
task
- to execute.delay
- The time duration that is allowed to elapse before task
is executed.Cancellable
to cancel the task if not yet executed.java.util.concurrent.RejectedExecutionException
- If the task is rejected.