|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.concurrent.Executors
Factory and utility methods for Executor, ExecutorService, Future, and Cancellable classes
defined in this package.
| Method Summary | ||
static
|
execute(Executor executor,
Callable<T> task)
Executes a value-returning task and returns a Future representing the pending results of the task. |
|
static Cancellable |
execute(Executor executor,
java.lang.Runnable task)
Executes a Runnable task and returns a Cancellable representing that task. |
|
static
|
execute(Executor executor,
java.lang.Runnable task,
T value)
Executes a Runnable task and returns a Future representing that task. |
|
static
|
invoke(Executor executor,
Callable<T> task)
Executes a value-returning task and blocks until it returns a value or throws an exception. |
|
static void |
invoke(Executor executor,
java.lang.Runnable task)
Executes a Runnable task and blocks until it completes normally or throws an exception. |
|
static ExecutorService |
newCachedThreadPool()
Creates a thread pool that creates new threads as needed, but will reuse previously constructed threads when they are available. |
|
static ExecutorService |
newCachedThreadPool(ThreadFactory threadFactory)
Creates a thread pool that creates new threads as needed, but will reuse previously constructed threads when they are available, and uses the provided ThreadFactory to create new threads when needed. |
|
static ExecutorService |
newFixedThreadPool(int nThreads)
Creates a thread pool that reuses a fixed set of threads operating off a shared unbounded queue. |
|
static ExecutorService |
newFixedThreadPool(int nThreads,
ThreadFactory threadFactory)
Creates a thread pool that reuses a fixed set of threads operating off a shared unbounded queue, using the provided ThreadFactory to create new threads when needed. |
|
static ExecutorService |
newSingleThreadExecutor()
Creates an Executor that uses a single worker thread operating off an unbounded queue. |
|
static ExecutorService |
newSingleThreadExecutor(ThreadFactory threadFactory)
Creates an Executor that uses a single worker thread operating off an unbounded queue, and uses the provided ThreadFactory to create new threads when needed. |
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
public static ExecutorService newFixedThreadPool(int nThreads)
nThreads - the number of threads in the pool
public static ExecutorService newFixedThreadPool(int nThreads,
ThreadFactory threadFactory)
nThreads - the number of threads in the poolthreadFactory - the factory to use when creating new threads
public static ExecutorService newSingleThreadExecutor()
public static ExecutorService newSingleThreadExecutor(ThreadFactory threadFactory)
threadFactory - the factory to use when creating new
threads
public static ExecutorService newCachedThreadPool()
ThreadPoolExecutor constructors.
public static ExecutorService newCachedThreadPool(ThreadFactory threadFactory)
threadFactory - the factory to use when creating new threads
public static Cancellable execute(Executor executor,
java.lang.Runnable task)
executor - the Executor to which the task will be submittedtask - the task to submit
RejectedExecutionException - if task cannot be scheduled
for execution
public static <T> Future<T> execute(Executor executor,
java.lang.Runnable task,
T value)
executor - the Executor to which the task will be submittedtask - the task to submitvalue - the value which will become the return value of
the task upon task completion
RejectedExecutionException - if task cannot be scheduled
for execution
public static <T> Future<T> execute(Executor executor,
Callable<T> task)
executor - the Executor to which the task will be submittedtask - the task to submit
RejectedExecutionException - if task cannot be scheduled
for execution
public static void invoke(Executor executor,
java.lang.Runnable task)
throws ExecutionException,
java.lang.InterruptedException
executor - the Executor to which the task will be submittedtask - the task to submit
RejectedExecutionException - if task cannot be scheduled
for execution
ExecutionException - if the task encountered an exception
while executing
java.lang.InterruptedException
public static <T> T invoke(Executor executor,
Callable<T> task)
throws ExecutionException,
java.lang.InterruptedException
executor - the Executor to which the task will be submittedtask - the task to submit
RejectedExecutionException - if task cannot be scheduled
for execution
java.lang.InterruptedException - if interrupted while waiting for
completion
ExecutionException - if the task encountered an exception
while executing
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||