Blocks until all tasks have completed execution after a shutdown request, or the timeout occurs, or the current thread is interrupted, whichever happens first.
protected int
drainTasksTo(Collection<? super ForkJoinTask<?>> c)
Removes all available unexecuted submitted and forked tasks from scheduling queues and adds them to the given collection, without altering their execution status.
void
execute(ForkJoinTask<?> task)
Arranges for (asynchronous) execution of the given task.
void
execute(Runnable task)
Executes the given command at some time in the future.
int
getActiveThreadCount()
Returns an estimate of the number of threads that are currently stealing or executing tasks.
boolean
getAsyncMode()
Returns
true
if this pool uses local first-in-first-out scheduling mode for forked tasks that are never joined.
ForkJoinPool.ForkJoinWorkerThreadFactory
getFactory()
Returns the factory used for constructing new workers.
int
getParallelism()
Returns the targeted parallelism level of this pool.
int
getPoolSize()
Returns the number of worker threads that have started but not yet terminated.
int
getQueuedSubmissionCount()
Returns an estimate of the number of tasks submitted to this pool that have not yet begun executing.
long
getQueuedTaskCount()
Returns an estimate of the total number of tasks currently held in queues by worker threads (but not including tasks submitted to the pool that have not begun executing).
int
getRunningThreadCount()
Returns an estimate of the number of worker threads that are not blocked waiting to join tasks or for other managed synchronization.
long
getStealCount()
Returns an estimate of the total number of tasks stolen from one thread's work queue by another.
Thread.UncaughtExceptionHandler
getUncaughtExceptionHandler()
Returns the handler for internal worker threads that terminate due to unrecoverable errors encountered while executing tasks.
boolean
hasQueuedSubmissions()
Returns
true
if there are any tasks submitted to this pool that have not yet begun executing.
<T> T
invoke(ForkJoinTask<T> task)
Performs the given task, returning its result upon completion.
Executes the given tasks, returning a list of Futures holding their status and results when all complete.
boolean
isQuiescent()
Returns
true
if all worker threads are currently idle.
boolean
isShutdown()
Returns
true
if this pool has been shut down.
boolean
isTerminated()
Returns
true
if all tasks have completed following shut down.
boolean
isTerminating()
Returns
true
if the process of termination has commenced but not yet completed.
static void
managedBlock(ForkJoinPool.ManagedBlocker blocker)
Blocks in accord with the given blocker.
protected <T> RunnableFuture<T>
newTaskFor(Callable<T> callable)
Returns a RunnableFuture for the given callable task.
protected <T> RunnableFuture<T>
newTaskFor(Runnable runnable, T value)
Returns a RunnableFuture for the given runnable and default value.
protected ForkJoinTask<?>
pollSubmission()
Removes and returns the next unexecuted submission if one is available.
void
shutdown()
Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted.
List<Runnable>
shutdownNow()
Attempts to cancel and/or stop all tasks, and reject all subsequently submitted tasks.
<T> ForkJoinTask<T>
submit(Callable<T> task)
Submits a value-returning task for execution and returns a Future representing the pending results of the task.
<T> ForkJoinTask<T>
submit(ForkJoinTask<T> task)
Submits a ForkJoinTask for execution.
ForkJoinTask<?>
submit(Runnable task)
Submits a Runnable task for execution and returns a Future representing that task.
<T> ForkJoinTask<T>
submit(Runnable task, T result)
Submits a Runnable task for execution and returns a Future representing that task.
String
toString()
Returns a string identifying this pool, as well as its state, including indications of run state, parallelism level, and worker and task counts.
ExecutorService接口
方法摘要
Methods
修飾符與類型
方法與描述
boolean
awaitTermination(long timeout, TimeUnit unit)
Blocks until all tasks have completed execution after a shutdown request, or the timeout occurs, or the current thread is interrupted, whichever happens first.
Executes the given tasks, returning a list of Futures holding their status and results when all complete.
<T> List<Future<T>>
invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
Executes the given tasks, returning a list of Futures holding their status and results when all complete or the timeout expires, whichever happens first.
Executes the given tasks, returning the result of one that has completed successfully (i.e., without throwing an exception), if any do.
<T> T
invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
Executes the given tasks, returning the result of one that has completed successfully (i.e., without throwing an exception), if any do before the given timeout elapses.
boolean
isShutdown()
Returns true if this executor has been shut down.
boolean
isTerminated()
Returns true if all tasks have completed following shut down.
void
shutdown()
Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted.
List<Runnable>
shutdownNow()
Attempts to stop all actively executing tasks, halts the processing of waiting tasks, and returns a list of the tasks that were awaiting execution.
<T> Future<T>
submit(Callable<T> task)
Submits a value-returning task for execution and returns a Future representing the pending results of the task.
Future<?>
submit(Runnable task)
Submits a Runnable task for execution and returns a Future representing that task.
<T> Future<T>
submit(Runnable task, T result)
Submits a Runnable task for execution and returns a Future representing that task.