Package javascalautils.concurrent
Interface Executor
-
public interface ExecutorExecutor service used to execute work in asynchronous fashion.
In contrast to theExecutorservice provided by the Java SDK this returns non-blockingFutureinstances.- Since:
- 1.2
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanawaitTermination(long timeout, java.util.concurrent.TimeUnit unit)Blocks until all tasks have completed execution after a shutdown request, or the timeout occurs, or the current thread is interrupted, whichever happens first.<T> Future<T>execute(java.util.concurrent.Callable<T> callable)Executes the providedCallablesometime in the future.<T> Future<T>execute(Executable<T> executable)Executes the providedExecutablesometime in the future.<T> java.util.List<Future<T>>executeAll(java.util.concurrent.Callable<T>... callables)Executes the list of providedCallablesometime in the future.<T> java.util.List<Future<T>>executeAll(Executable<T>... executables)Executes the list of providedExecutablesometime in the future.voidshutdown()Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted.
-
-
-
Method Detail
-
execute
<T> Future<T> execute(Executable<T> executable)
Executes the providedExecutablesometime in the future.- Type Parameters:
T- The type the Future is expected to deliver- Parameters:
executable- The executable to execute- Returns:
- The future acting as a place holder for a response-to-be
- Since:
- 1.2
-
execute
<T> Future<T> execute(java.util.concurrent.Callable<T> callable)
Executes the providedCallablesometime in the future.- Type Parameters:
T- The type the Future is expected to deliver- Parameters:
callable- The callable to execute- Returns:
- The future acting as a place holder for a response-to-be
- Since:
- 1.2
-
executeAll
<T> java.util.List<Future<T>> executeAll(Executable<T>... executables)
Executes the list of providedExecutablesometime in the future.- Type Parameters:
T- The type the Future is expected to deliver- Parameters:
executables- The list of executables to execute- Returns:
- List of futures acting as a place holder for a response-to-be
- Since:
- 1.2
-
executeAll
<T> java.util.List<Future<T>> executeAll(java.util.concurrent.Callable<T>... callables)
Executes the list of providedCallablesometime in the future.- Type Parameters:
T- The type the Future is expected to deliver- Parameters:
callables- The list of callables to execute- Returns:
- List of futures acting as a place holder for a response-to-be
- Since:
- 1.2
-
shutdown
void shutdown()
Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted. Invocation has no additional effect if already shut down.- Since:
- 1.2
-
awaitTermination
boolean awaitTermination(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedExceptionBlocks until all tasks have completed execution after a shutdown request, or the timeout occurs, or the current thread is interrupted, whichever happens first.- Parameters:
timeout- the maximum time to waitunit- the time unit of the timeout argument- Returns:
trueif this executor terminated andfalseif the timeout elapsed before termination- Throws:
java.lang.InterruptedException- if interrupted while waiting- Since:
- 1.2
-
-