java.util.concurrent
Class ForkJoinPool

java.lang.Object
  extended by java.util.concurrent.AbstractExecutorService
      extended by java.util.concurrent.ForkJoinPool
All Implemented Interfaces:
Executor, ExecutorService

public class ForkJoinPool
extends AbstractExecutorService

Disabled: no SafeJ information.

An ExecutorService for running ForkJoinTasks. A ForkJoinPool provides the entry point for submissions from non-ForkJoinTasks, as well as management and monitoring operations.

A ForkJoinPool differs from other kinds of ExecutorService mainly by virtue of employing work-stealing: all threads in the pool attempt to find and execute subtasks created by other active tasks (eventually blocking waiting for work if none exist). This enables efficient processing when most tasks spawn other subtasks (as do most ForkJoinTasks). A ForkJoinPool may also be used for mixed execution of some plain Runnable- or Callable- based activities along with ForkJoinTasks. When setting async mode, a ForkJoinPool may also be appropriate for use with fine-grained tasks of any form that are never joined. Otherwise, other ExecutorService implementations are typically more appropriate choices.

A ForkJoinPool is constructed with a given target parallelism level; by default, equal to the number of available processors. Unless configured otherwise via setMaintainsParallelism(boolean), the pool attempts to maintain this number of active (or available) threads by dynamically adding, suspending, or resuming internal worker threads, even if some tasks are stalled waiting to join others. However, no such adjustments are performed in the face of blocked IO or other unmanaged synchronization. The nested ForkJoinPool.ManagedBlocker interface enables extension of the kinds of synchronization accommodated. The target parallelism level may also be changed dynamically (setParallelism(int)). The total number of threads may be limited using method setMaximumPoolSize(int), in which case it may become possible for the activities of a pool to stall due to the lack of available threads to process new tasks.

In addition to execution and lifecycle control methods, this class provides status check methods (for example getStealCount()) that are intended to aid in developing, tuning, and monitoring fork/join applications. Also, method toString() returns indications of pool state in a convenient form for informal monitoring.

Sample Usage. Normally a single ForkJoinPool is used for all parallel task execution in a program or subsystem. Otherwise, use would not usually outweigh the construction and bookkeeping overhead of creating a large set of threads. For example, a common pool could be used for the SortTasks illustrated in RecursiveAction. Because ForkJoinPool uses threads in daemon mode, there is typically no need to explicitly shutdown() such a pool upon program exit.

 static final ForkJoinPool mainPool = new ForkJoinPool();
 ...
 public void sort(long[] array) {
   mainPool.invoke(new SortTask(array, 0, array.length));
 }
 

Implementation notes: This implementation restricts the maximum number of running threads to 32767. Attempts to create pools with greater than the maximum number result in IllegalArgumentException.

This implementation rejects submitted tasks (that is, by throwing RejectedExecutionException) only when the pool is shut down.

Since:
1.7

Nested Class Summary
static interface ForkJoinPool.ForkJoinWorkerThreadFactory
          Factory for creating new ForkJoinWorkerThreads.
static interface ForkJoinPool.ManagedBlocker
          Interface for extending managed parallelism for tasks running in ForkJoinPools.
 
Field Summary
static ForkJoinPool.ForkJoinWorkerThreadFactory defaultForkJoinWorkerThreadFactory
          Creates a new ForkJoinWorkerThread.
 
Constructor Summary
ForkJoinPool()
          Creates a ForkJoinPool with parallelism equal to Runtime.availableProcessors(), and using the default thread factory.
ForkJoinPool(ForkJoinPool.ForkJoinWorkerThreadFactory factory)
          Creates a ForkJoinPool with parallelism equal to Runtime.availableProcessors(), and using the given thread factory.
ForkJoinPool(int parallelism)
          Creates a ForkJoinPool with the indicated parallelism level and using the default thread factory.
ForkJoinPool(int parallelism, ForkJoinPool.ForkJoinWorkerThreadFactory factory)
          Creates a ForkJoinPool with the given parallelism and thread factory.
 
Method Summary
 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.
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.
 boolean getMaintainsParallelism()
          Returns true if this pool dynamically maintains its target parallelism level.
 int getMaximumPoolSize()
          Returns the maximum number of threads allowed to exist in the pool.
 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.
<T> List<Future<T>>
invokeAll(Collection<? extends Callable<T>> tasks)
          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, boolean maintainParallelism)
          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.
 boolean setAsyncMode(boolean async)
          Establishes local first-in-first-out scheduling mode for forked tasks that are never joined.
 void setMaintainsParallelism(boolean enable)
          Sets whether this pool dynamically maintains its target parallelism level.
 void setMaximumPoolSize(int newMax)
          Sets the maximum number of threads allowed to exist in the pool.
 void setParallelism(int parallelism)
          Sets the target parallelism level of this pool.
 Thread.UncaughtExceptionHandler setUncaughtExceptionHandler(Thread.UncaughtExceptionHandler h)
          Sets the handler for internal worker threads that terminate due to unrecoverable errors encountered while executing tasks.
 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.
 
Methods inherited from class java.util.concurrent.AbstractExecutorService
invokeAll, invokeAny, invokeAny
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

defaultForkJoinWorkerThreadFactory

public static final ForkJoinPool.ForkJoinWorkerThreadFactory defaultForkJoinWorkerThreadFactory
Class is disabled.

Creates a new ForkJoinWorkerThread. This factory is used unless overridden in ForkJoinPool constructors.

Constructor Detail

ForkJoinPool

public ForkJoinPool()
Class is disabled.

Creates a ForkJoinPool with parallelism equal to Runtime.availableProcessors(), and using the default thread factory.

Throws:
SecurityException - if a security manager exists and the caller is not permitted to modify threads because it does not hold RuntimePermission("modifyThread")

ForkJoinPool

public ForkJoinPool(int parallelism)
Class is disabled.

Creates a ForkJoinPool with the indicated parallelism level and using the default thread factory.

Parameters:
parallelism - the parallelism level
Throws:
IllegalArgumentException - if parallelism less than or equal to zero, or greater than implementation limit
SecurityException - if a security manager exists and the caller is not permitted to modify threads because it does not hold RuntimePermission("modifyThread")

ForkJoinPool

public ForkJoinPool(ForkJoinPool.ForkJoinWorkerThreadFactory factory)
Class is disabled.

Creates a ForkJoinPool with parallelism equal to Runtime.availableProcessors(), and using the given thread factory.

Parameters:
factory - the factory for creating new threads
Throws:
NullPointerException - if the factory is null
SecurityException - if a security manager exists and the caller is not permitted to modify threads because it does not hold RuntimePermission("modifyThread")

ForkJoinPool

public ForkJoinPool(int parallelism,
                    ForkJoinPool.ForkJoinWorkerThreadFactory factory)
Class is disabled.

Creates a ForkJoinPool with the given parallelism and thread factory.

Parameters:
parallelism - the parallelism level
factory - the factory for creating new threads
Throws:
IllegalArgumentException - if parallelism less than or equal to zero, or greater than implementation limit
NullPointerException - if the factory is null
SecurityException - if a security manager exists and the caller is not permitted to modify threads because it does not hold RuntimePermission("modifyThread")
Method Detail

invoke

public <T> T invoke(ForkJoinTask<T> task)
Class is disabled.

Performs the given task, returning its result upon completion.

Parameters:
task - the task
Returns:
the task's result
Throws:
NullPointerException - if the task is null
RejectedExecutionException - if the task cannot be scheduled for execution

execute

public void execute(ForkJoinTask<?> task)
Class is disabled.

Arranges for (asynchronous) execution of the given task.

Parameters:
task - the task
Throws:
NullPointerException - if the task is null
RejectedExecutionException - if the task cannot be scheduled for execution

execute

public void execute(Runnable task)
Class is disabled.

Description copied from interface: Executor
Executes the given command at some time in the future. The command may execute in a new thread, in a pooled thread, or in the calling thread, at the discretion of the Executor implementation.

Parameters:
task - the runnable task
Throws:
NullPointerException - if the task is null
RejectedExecutionException - if the task cannot be scheduled for execution

submit

public <T> ForkJoinTask<T> submit(Callable<T> task)
Class is disabled.

Description copied from interface: ExecutorService
Submits a value-returning task for execution and returns a Future representing the pending results of the task. The Future's get method will return the task's result upon successful completion.

If you would like to immediately block waiting for a task, you can use constructions of the form result = exec.submit(aCallable).get();

Note: The Executors class includes a set of methods that can convert some other common closure-like objects, for example, PrivilegedAction to Callable form so they can be submitted.

Specified by:
submit in interface ExecutorService
Overrides:
submit in class AbstractExecutorService
Parameters:
task - the task to submit
Returns:
a Future representing pending completion of the task
Throws:
NullPointerException - if the task is null
RejectedExecutionException - if the task cannot be scheduled for execution

submit

public <T> ForkJoinTask<T> submit(Runnable task,
                                  T result)
Class is disabled.

Description copied from interface: ExecutorService
Submits a Runnable task for execution and returns a Future representing that task. The Future's get method will return the given result upon successful completion.

Specified by:
submit in interface ExecutorService
Overrides:
submit in class AbstractExecutorService
Parameters:
task - the task to submit
result - the result to return
Returns:
a Future representing pending completion of the task
Throws:
NullPointerException - if the task is null
RejectedExecutionException - if the task cannot be scheduled for execution

submit

public ForkJoinTask<?> submit(Runnable task)
Class is disabled.

Description copied from interface: ExecutorService
Submits a Runnable task for execution and returns a Future representing that task. The Future's get method will return null upon successful completion.

Specified by:
submit in interface ExecutorService
Overrides:
submit in class AbstractExecutorService
Parameters:
task - the task to submit
Returns:
a Future representing pending completion of the task
Throws:
NullPointerException - if the task is null
RejectedExecutionException - if the task cannot be scheduled for execution

submit

public <T> ForkJoinTask<T> submit(ForkJoinTask<T> task)
Class is disabled.

Submits a ForkJoinTask for execution.

Parameters:
task - the task to submit
Returns:
the task
Throws:
NullPointerException - if the task is null
RejectedExecutionException - if the task cannot be scheduled for execution

invokeAll

public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks)
Class is disabled.

Description copied from interface: ExecutorService
Executes the given tasks, returning a list of Futures holding their status and results when all complete. Future.isDone() is true for each element of the returned list. Note that a completed task could have terminated either normally or by throwing an exception. The results of this method are undefined if the given collection is modified while this operation is in progress.

Specified by:
invokeAll in interface ExecutorService
Overrides:
invokeAll in class AbstractExecutorService
Parameters:
tasks - the collection of tasks
Returns:
A list of Futures representing the tasks, in the same sequential order as produced by the iterator for the given task list, each of which has completed.
Throws:
NullPointerException - if tasks or any of its elements are null
RejectedExecutionException - if any task cannot be scheduled for execution

getFactory

public ForkJoinPool.ForkJoinWorkerThreadFactory getFactory()
Class is disabled.

Returns the factory used for constructing new workers.

Returns:
the factory used for constructing new workers

getUncaughtExceptionHandler

public Thread.UncaughtExceptionHandler getUncaughtExceptionHandler()
Class is disabled.

Returns the handler for internal worker threads that terminate due to unrecoverable errors encountered while executing tasks.

Returns:
the handler, or null if none

setUncaughtExceptionHandler

public Thread.UncaughtExceptionHandler setUncaughtExceptionHandler(Thread.UncaughtExceptionHandler h)
Class is disabled.

Sets the handler for internal worker threads that terminate due to unrecoverable errors encountered while executing tasks. Unless set, the current default or ThreadGroup handler is used as handler.

Parameters:
h - the new handler
Returns:
the old handler, or null if none
Throws:
SecurityException - if a security manager exists and the caller is not permitted to modify threads because it does not hold RuntimePermission("modifyThread")

setParallelism

public void setParallelism(int parallelism)
Class is disabled.

Sets the target parallelism level of this pool.

Parameters:
parallelism - the target parallelism
Throws:
IllegalArgumentException - if parallelism less than or equal to zero or greater than maximum size bounds
SecurityException - if a security manager exists and the caller is not permitted to modify threads because it does not hold RuntimePermission("modifyThread")

getParallelism

public int getParallelism()
Class is disabled.

Returns the targeted parallelism level of this pool.

Returns:
the targeted parallelism level of this pool

getPoolSize

public int getPoolSize()
Class is disabled.

Returns the number of worker threads that have started but not yet terminated. This result returned by this method may differ from getParallelism() when threads are created to maintain parallelism when others are cooperatively blocked.

Returns:
the number of worker threads

getMaximumPoolSize

public int getMaximumPoolSize()
Class is disabled.

Returns the maximum number of threads allowed to exist in the pool. Unless set using setMaximumPoolSize(int), the maximum is an implementation-defined value designed only to prevent runaway growth.

Returns:
the maximum

setMaximumPoolSize

public void setMaximumPoolSize(int newMax)
Class is disabled.

Sets the maximum number of threads allowed to exist in the pool. The given value should normally be greater than or equal to the parallelism level. Setting this value has no effect on current pool size. It controls construction of new threads.

Throws:
IllegalArgumentException - if negative or greater than internal implementation limit

getMaintainsParallelism

public boolean getMaintainsParallelism()
Class is disabled.

Returns true if this pool dynamically maintains its target parallelism level. If false, new threads are added only to avoid possible starvation. This setting is by default true.

Returns:
true if maintains parallelism

setMaintainsParallelism

public void setMaintainsParallelism(boolean enable)
Class is disabled.

Sets whether this pool dynamically maintains its target parallelism level. If false, new threads are added only to avoid possible starvation.

Parameters:
enable - true to maintain parallelism

setAsyncMode

public boolean setAsyncMode(boolean async)
Class is disabled.

Establishes local first-in-first-out scheduling mode for forked tasks that are never joined. This mode may be more appropriate than default locally stack-based mode in applications in which worker threads only process asynchronous tasks. This method is designed to be invoked only when the pool is quiescent, and typically only before any tasks are submitted. The effects of invocations at other times may be unpredictable.

Parameters:
async - if true, use locally FIFO scheduling
Returns:
the previous mode
See Also:
getAsyncMode()

getAsyncMode

public boolean getAsyncMode()
Class is disabled.

Returns true if this pool uses local first-in-first-out scheduling mode for forked tasks that are never joined.

Returns:
true if this pool uses async mode
See Also:
setAsyncMode(boolean)

getRunningThreadCount

public int getRunningThreadCount()
Class is disabled.

Returns an estimate of the number of worker threads that are not blocked waiting to join tasks or for other managed synchronization.

Returns:
the number of worker threads

getActiveThreadCount

public int getActiveThreadCount()
Class is disabled.

Returns an estimate of the number of threads that are currently stealing or executing tasks. This method may overestimate the number of active threads.

Returns:
the number of active threads

isQuiescent

public boolean isQuiescent()
Class is disabled.

Returns true if all worker threads are currently idle. An idle worker is one that cannot obtain a task to execute because none are available to steal from other threads, and there are no pending submissions to the pool. This method is conservative; it might not return true immediately upon idleness of all threads, but will eventually become true if threads remain inactive.

Returns:
true if all threads are currently idle

getStealCount

public long getStealCount()
Class is disabled.

Returns an estimate of the total number of tasks stolen from one thread's work queue by another. The reported value underestimates the actual total number of steals when the pool is not quiescent. This value may be useful for monitoring and tuning fork/join programs: in general, steal counts should be high enough to keep threads busy, but low enough to avoid overhead and contention across threads.

Returns:
the number of steals

getQueuedTaskCount

public long getQueuedTaskCount()
Class is disabled.

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). This value is only an approximation, obtained by iterating across all threads in the pool. This method may be useful for tuning task granularities.

Returns:
the number of queued tasks

getQueuedSubmissionCount

public int getQueuedSubmissionCount()
Class is disabled.

Returns an estimate of the number of tasks submitted to this pool that have not yet begun executing. This method takes time proportional to the number of submissions.

Returns:
the number of queued submissions

hasQueuedSubmissions

public boolean hasQueuedSubmissions()
Class is disabled.

Returns true if there are any tasks submitted to this pool that have not yet begun executing.

Returns:
true if there are any queued submissions

pollSubmission

protected ForkJoinTask<?> pollSubmission()
Class is disabled.

Removes and returns the next unexecuted submission if one is available. This method may be useful in extensions to this class that re-assign work in systems with multiple pools.

Returns:
the next submission, or null if none

drainTasksTo

protected int drainTasksTo(Collection<? super ForkJoinTask<?>> c)
Class is disabled.

Removes all available unexecuted submitted and forked tasks from scheduling queues and adds them to the given collection, without altering their execution status. These may include artificially generated or wrapped tasks. This method is designed to be invoked only when the pool is known to be quiescent. Invocations at other times may not remove all tasks. A failure encountered while attempting to add elements to collection c may result in elements being in neither, either or both collections when the associated exception is thrown. The behavior of this operation is undefined if the specified collection is modified while the operation is in progress.

Parameters:
c - the collection to transfer elements into
Returns:
the number of elements transferred

toString

public String toString()
Class is disabled.

Returns a string identifying this pool, as well as its state, including indications of run state, parallelism level, and worker and task counts.

Overrides:
toString in class Object
Returns:
a string identifying this pool, as well as its state

shutdown

public void shutdown()
Class is disabled.

Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted. Invocation has no additional effect if already shut down. Tasks that are in the process of being submitted concurrently during the course of this method may or may not be rejected.

Throws:
SecurityException - if a security manager exists and the caller is not permitted to modify threads because it does not hold RuntimePermission("modifyThread")

shutdownNow

public List<Runnable> shutdownNow()
Class is disabled.

Attempts to cancel and/or stop all tasks, and reject all subsequently submitted tasks. Tasks that are in the process of being submitted or executed concurrently during the course of this method may or may not be rejected. This method cancels both existing and unexecuted tasks, in order to permit termination in the presence of task dependencies. So the method always returns an empty list (unlike the case for some other Executors).

Returns:
an empty list
Throws:
SecurityException - if a security manager exists and the caller is not permitted to modify threads because it does not hold RuntimePermission("modifyThread")

isTerminated

public boolean isTerminated()
Class is disabled.

Returns true if all tasks have completed following shut down.

Returns:
true if all tasks have completed following shut down

isTerminating

public boolean isTerminating()
Class is disabled.

Returns true if the process of termination has commenced but not yet completed. This method may be useful for debugging. A return of true reported a sufficient period after shutdown may indicate that submitted tasks have ignored or suppressed interruption, causing this executor not to properly terminate.

Returns:
true if terminating but not yet terminated

isShutdown

public boolean isShutdown()
Class is disabled.

Returns true if this pool has been shut down.

Returns:
true if this pool has been shut down

awaitTermination

public boolean awaitTermination(long timeout,
                                TimeUnit unit)
                         throws InterruptedException
Class is disabled.

Blocks until all tasks have completed execution after a shutdown request, or the timeout occurs, or the current thread is interrupted, whichever happens first.

Parameters:
timeout - the maximum time to wait
unit - the time unit of the timeout argument
Returns:
true if this executor terminated and false if the timeout elapsed before termination
Throws:
InterruptedException - if interrupted while waiting

managedBlock

public static void managedBlock(ForkJoinPool.ManagedBlocker blocker,
                                boolean maintainParallelism)
                         throws InterruptedException
Class is disabled.

Blocks in accord with the given blocker. If the current thread is a ForkJoinWorkerThread, this method possibly arranges for a spare thread to be activated if necessary to ensure parallelism while the current thread is blocked.

If maintainParallelism is true and the pool supports it (getMaintainsParallelism()), this method attempts to maintain the pool's nominal parallelism. Otherwise it activates a thread only if necessary to avoid complete starvation. This option may be preferable when blockages use timeouts, or are almost always brief.

If the caller is not a ForkJoinTask, this method is behaviorally equivalent to

 while (!blocker.isReleasable())
   if (blocker.block())
     return;
 
If the caller is a ForkJoinTask, then the pool may first be expanded to ensure parallelism, and later adjusted.

Parameters:
blocker - the blocker
maintainParallelism - if true and supported by this pool, attempt to maintain the pool's nominal parallelism; otherwise activate a thread only if necessary to avoid complete starvation.
Throws:
InterruptedException - if blocker.block did so

newTaskFor

protected <T> RunnableFuture<T> newTaskFor(Runnable runnable,
                                           T value)
Class is disabled.

Description copied from class: AbstractExecutorService
Returns a RunnableFuture for the given runnable and default value.

Overrides:
newTaskFor in class AbstractExecutorService
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.

newTaskFor

protected <T> RunnableFuture<T> newTaskFor(Callable<T> callable)
Class is disabled.

Description copied from class: AbstractExecutorService
Returns a RunnableFuture for the given callable task.

Overrides:
newTaskFor in class AbstractExecutorService
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.