Package javascalautils.concurrent
Interface Executor
-
public interface Executor
Executor service used to execute work in asynchronous fashion.
In contrast to theExecutor
service provided by the Java SDK this returns non-blockingFuture
instances.- Since:
- 1.2
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
awaitTermination(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 providedCallable
sometime in the future.<T> Future<T>
execute(Executable<T> executable)
Executes the providedExecutable
sometime in the future.<T> java.util.List<Future<T>>
executeAll(java.util.concurrent.Callable<T>... callables)
Executes the list of providedCallable
sometime in the future.<T> java.util.List<Future<T>>
executeAll(Executable<T>... executables)
Executes the list of providedExecutable
sometime in the future.void
shutdown()
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 providedExecutable
sometime 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 providedCallable
sometime 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 providedExecutable
sometime 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 providedCallable
sometime 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.InterruptedException
Blocks 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:
true
if this executor terminated andfalse
if the timeout elapsed before termination- Throws:
java.lang.InterruptedException
- if interrupted while waiting- Since:
- 1.2
-
-