Home » openjdk-7 » java » util » concurrent » [javadoc | source]
abstract public class: AbstractExecutorService [javadoc | source]

All Implemented Interfaces:

Direct Known Subclasses:
    ThreadPoolExecutor, DelegatedExecutorService, ScheduledThreadPoolExecutor, FinalizableDelegatedExecutorService, ForkJoinPool, DelegatedScheduledExecutorService

Provides default implementations of ExecutorService execution methods. This class implements the submit, invokeAny and invokeAll methods using a RunnableFuture returned by newTaskFor, which defaults to the FutureTask class provided in this package. For example, the implementation of submit(Runnable) creates an associated RunnableFuture that is executed and returned. Subclasses may override the newTaskFor methods to return RunnableFuture implementations other than FutureTask.

Extension example. Here is a sketch of a class that customizes ThreadPoolExecutor to use a CustomTask class instead of the default FutureTask:

public class CustomThreadPoolExecutor extends ThreadPoolExecutor {

  static class CustomTask implements RunnableFuture {...}

  protected  RunnableFuture newTaskFor(Callable c) {
      return new CustomTask(c);
  protected  RunnableFuture newTaskFor(Runnable r, V v) {
      return new CustomTask(r, v);
  // ... add constructors, etc.
Method from java.util.concurrent.AbstractExecutorService Summary:
invokeAll,   invokeAll,   invokeAny,   invokeAny,   newTaskFor,   newTaskFor,   submit,   submit,   submit
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from java.util.concurrent.AbstractExecutorService Detail:
 public List<T> invokeAll(Collection<Callable> tasks) throws InterruptedException 
 public List<T> invokeAll(Collection<Callable> tasks,
    long timeout,
    TimeUnit unit) throws InterruptedException 
 public T invokeAny(Collection<Callable> tasks) throws InterruptedException, ExecutionException 
 public T invokeAny(Collection<Callable> tasks,
    long timeout,
    TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException 
 protected RunnableFuture<T> newTaskFor(Callable<T> callable) 
    Returns a RunnableFuture for the given callable task.
 protected RunnableFuture<T> newTaskFor(Runnable runnable,
    T value) 
    Returns a RunnableFuture for the given runnable and default value.
 public Future<?> submit(Runnable task) 
 public Future<T> submit(Callable<T> task) 
 public Future<T> submit(Runnable task,
    T result)