/*
* Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain. Use, modify, and
* redistribute this code in any way without acknowledgement.
*/
package java.util.concurrent;
import java.util.List;
import java.security.PrivilegedAction;
import java.security.PrivilegedExceptionAction;
/**
* An Executor that provides methods to manage termination.
* An ExecutorService can be shut down, which will cause it
* to stop accepting new tasks. After being shut down, the executor
* will eventually terminate, at which point no tasks are actively
* executing, no tasks are awaiting execution, and no new tasks can be
* submitted.
*
*
The {@link Executors} class provides factory methods for the
* executor services provided in this package.
*
* @since 1.5
* @author Doug Lea
*/
public interface ExecutorService extends Executor {
/**
* Submits a Runnable task for execution and returns a Future
* representing that task.
*
* @param task the task to submit
* @return a Future representing pending completion of the task,
* and whose get() method will return an arbitrary value
* upon completion
* @throws RejectedExecutionException if task cannot be scheduled
* for execution
*/
Future> submit(Runnable task);
/**
* Submits a value-returning task for execution and returns a Future
* representing the pending results of the task.
*
* @param task the task to submit
* @return a Future representing pending completion of the task
* @throws RejectedExecutionException if task cannot be scheduled
* for execution
*/
Future submit(Callable task);
/**
* Executes a Runnable task and blocks until it completes normally
* or throws an exception.
*
* @param task the task to submit
* @throws RejectedExecutionException if task cannot be scheduled
* for execution
* @throws ExecutionException if the task encountered an exception
* while executing
*/
void invoke(Runnable task) throws ExecutionException, InterruptedException;
/**
* Executes a value-returning task and blocks until it returns a
* value or throws an exception.
*
* @param task the task to submit
* @return a Future representing pending completion of the task
* @throws RejectedExecutionException if task cannot be scheduled
* for execution
* @throws InterruptedException if interrupted while waiting for
* completion
* @throws ExecutionException if the task encountered an exception
* while executing
*/
T invoke(Callable task) throws ExecutionException, InterruptedException;
/**
* Submits a privileged action for execution under the current
* access control context and returns a Future representing the
* pending result object of that action.
*
* @param action the action to submit
* @return a Future representing pending completion of the action
* @throws RejectedExecutionException if action cannot be scheduled
* for execution
*/
Future