- All Superinterfaces:
Executor
- All Known Implementing Classes:
XnioIoThread
An executor with the capability to run timed, cancellable tasks.
- Author:
- David M. Lloyd
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
A task key for a timeout task. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Execute a task in this executor.executeAfter
(Runnable command, long time, TimeUnit unit) Execute a command after a period of time.executeAtInterval
(Runnable command, long time, TimeUnit unit) Execute a command repeatedly at a time interval until it is cancelled.
-
Method Details
-
execute
Execute a task in this executor. -
executeAfter
Execute a command after a period of time. At least the amount of time given intime
will have elapsed when the task is run. The returned key may be used to cancel the task before it runs.- Parameters:
command
- the command to executetime
- the amount of time to delay, or0
to run immediatelyunit
- the time unit to apply totime
- Returns:
- a key which may be used to cancel this task before it executes
-
executeAtInterval
Execute a command repeatedly at a time interval until it is cancelled. At least the amount of time given intime
will have elapsed when the task is first run, and again for each subsequent run. The returned key may be used to cancel the task before it runs.- Parameters:
command
- the command to executetime
- the amount of time to delay, or0
to run immediatelyunit
- the time unit to apply totime
- Returns:
- a key which may be used to cancel this task before it executes
-