This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.


java.util.concurrent
class AbstractExecutorService

java.lang.Object extended by java.util.concurrent.AbstractExecutorService
All Implemented Interfaces:
ExecutorService
Direct Known Subclasses:
ThreadPoolExecutor

public abstract class AbstractExecutorService
extends Object
implements ExecutorService

Provides default implementations of {@link ExecutorService} execution methods. This class implements the submit, invokeAny and invokeAll methods using a {@link RunnableFuture} returned by newTaskFor, which defaults to the {@link 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 {@link ThreadPoolExecutor} to use a CustomTask class instead of the default FutureTask:

 public class CustomThreadPoolExecutor extends ThreadPoolExecutor {

   static class CustomTask<V> implements RunnableFuture<V> {...}

   protected <V> RunnableFuture<V> newTaskFor(Callable<V> c) {
       return new CustomTask<V>(c);
   }
   protected <V> RunnableFuture<V> newTaskFor(Runnable r, V v) {
       return new CustomTask<V>(r, v);
   }
   // ... add constructors, etc.
 }
 


Constructor Summary

          
 
Method Summary
 List

          
 List
invokeAll(Collection tasks, long timeout, TimeUnit unit)

          
 Object

          
 Object
invokeAny(Collection tasks, long timeout, TimeUnit unit)

          
protected RunnableFuture
newTaskFor(Callable callable)

          Returns a RunnableFuture for the given callable task.
protected RunnableFuture
newTaskFor(Runnable runnable, Object value)

          Returns a RunnableFuture for the given runnable and default value.
 Future

          
 Future

          
 Future
submit(Runnable task, Object result)

          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractExecutorService

public AbstractExecutorService()
Method Detail

invokeAll

public List invokeAll(Collection tasks)
               throws InterruptedException
Parameters:
tasks
Throws:
InterruptedException

invokeAll

public List invokeAll(Collection tasks,
                      long timeout,
                      TimeUnit unit)
               throws InterruptedException
Parameters:
tasks
timeout
unit
Throws:
InterruptedException

invokeAny

public Object invokeAny(Collection tasks)
                 throws InterruptedException,
                        ExecutionException
Parameters:
tasks
Throws:
InterruptedException
ExecutionException

invokeAny

public Object invokeAny(Collection tasks,
                        long timeout,
                        TimeUnit unit)
                 throws InterruptedException,
                        ExecutionException,
                        TimeoutException
Parameters:
tasks
timeout
unit
Throws:
InterruptedException
ExecutionException
TimeoutException

newTaskFor

protected RunnableFuture newTaskFor(Callable callable)
Returns a RunnableFuture for the given callable task.

Parameters:
callable - the callable task being wrapped
Returns:
a RunnableFuture which when run will call the underlying callable and which, as a Future, will yield the callable's result as its result and provide for cancellation of the underlying task.

newTaskFor

protected RunnableFuture newTaskFor(Runnable runnable,
                                    Object value)
Returns a RunnableFuture for the given runnable and default value.

Parameters:
runnable - the runnable task being wrapped
value - the default value for the returned future
Returns:
a RunnableFuture which when run will run the underlying runnable and which, as a Future, will yield the given value as its result and provide for cancellation of the underlying task.

submit

public Future submit(Callable task)
Parameters:
task

submit

public Future submit(Runnable task)
Parameters:
task

submit

public Future submit(Runnable task,
                     Object result)
Parameters:
task
result


This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.
This page displays the Jadeite version of the documention, which is derived from the offical documentation that contains this copyright notice:
Copyright 2008 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
The official Sun™ documentation can be found here at http://java.sun.com/javase/6/docs/api/.