Java in a Nutshell, 5th Edition [Electronic resources]

نسخه متنی -صفحه : 1191/ 768
نمايش فراداده

AbstractExecutorServicejava.util.concurrent

Java 5.0

This abstract class implements the submit( ), invokeAll( ), and invokeAny( ) methods of the ExecutorService interface. It does not implement the ExecutorService shutdown methods or the crucial execute( ) method for asynchronous execution of Runnable tasks.

The methods implemented by AbstractExecutorService wrap the submitted Callable or Runnable task in a FutureTask object. FutureTask implements Runnable and Future, which are first passed to the abstract execute( ) method to be run asynchronously and then returned to the caller.

See ThreadPoolExecutor for a concrete implementation, and see Executors for convenient ExecutorService factory methods.

Figure 16-70. java.util.concurrent.AbstractExecutorService

public abstract class

AbstractExecutorService implements ExecutorService { // Public Constructors public

AbstractExecutorService ( ); // Methods Implementing ExecutorService public <T> java.util.List<Future<T>>

invokeAll (java.util.Collection<Callable<T>>

tasks ) throws InterruptedException; public <T> java.util.List<Future<T>>

invokeAll (java.util.Collection<Callable<T>>

tasks , long

timeout , TimeUnit

unit ) throws InterruptedException; public <T> T

invokeAny (java.util.Collection<Callable<T>>

tasks ) throws InterruptedException, ExecutionException; public <T> T

invokeAny (java.util.Collection<Callable<T>>

tasks , long

timeout , TimeUnit

unit ) throws InterruptedException, ExecutionException, TimeoutException; public Future<?>

submit (Runnable

task ); public <T> Future<T>

submit (Callable<T>

task ); public <T> Future<T>

submit (Runnable

task , T

result ); }

Subclasses

ThreadPoolExecutor