- All Superinterfaces:
AutoCloseable,Closeable
A simplified
ExecutorService that can execute
InterruptableTasks and can be efficiently terminated. A thread that is
waiting to read on an open connection cannot be efficiently stopped. This
executor will query the thread and interrupt it if possible. It is important
to efficiently shut down the webserver in certain environments.-
Method Summary
Modifier and TypeMethodDescription<T> Future<T> execute(InterruptableTask<T> task) Executes a task.voidForce termination by forcefully interrupting all tasks.booleanVerifies if the executor is terminated.booleanTerminate executor waiting for any running task to complete for a specified timeout period.
-
Method Details
-
execute
Executes a task.- Type Parameters:
T- type ov value returned by task- Parameters:
task- an interruptable task- Returns:
- a future for a value returned by the task
-
isTerminated
boolean isTerminated()Verifies if the executor is terminated.- Returns:
- outcome of test
-
terminate
Terminate executor waiting for any running task to complete for a specified timeout period. It will only wait for thoseInterruptableTasks that are not interruptable.- Parameters:
timeout- timeout periodunit- timeout period unit- Returns:
- outcome of shutdown process
-
forceTerminate
void forceTerminate()Force termination by forcefully interrupting all tasks. Shall only be called ifterminate(long, java.util.concurrent.TimeUnit)returnsfalse.
-