public class CancelableExecutor
extends java.util.concurrent.ThreadPoolExecutor
ThreadPoolExecutor
that returns
Future
instances that, when canceled,
will invoke CancelableCallable.cancel()
if the submitted
Callable
is a CancelableCallable
.java.util.concurrent.ThreadPoolExecutor.AbortPolicy, java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardOldestPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardPolicy
Constructor and Description |
---|
CancelableExecutor(int nThreads)
Creates a fixed size thread pool with the specified number of threads and
a shared unbounded queue.
|
CancelableExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
java.util.concurrent.TimeUnit unit,
java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue)
Creates an instance by invoking the super constructor with the specified
arguments.
|
CancelableExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
java.util.concurrent.TimeUnit unit,
java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue,
java.util.concurrent.RejectedExecutionHandler handler)
Creates an instance by invoking the super constructor with the specified
arguments.
|
CancelableExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
java.util.concurrent.TimeUnit unit,
java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue,
java.util.concurrent.ThreadFactory threadFactory)
Creates an instance by invoking the super constructor with the specified
arguments.
|
CancelableExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
java.util.concurrent.TimeUnit unit,
java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue,
java.util.concurrent.ThreadFactory threadFactory,
java.util.concurrent.RejectedExecutionHandler handler)
Creates an instance by invoking the super constructor with the specified
arguments.
|
Modifier and Type | Method and Description |
---|---|
protected <T> java.util.concurrent.RunnableFuture<T> |
newTaskFor(java.util.concurrent.Callable<T> callable) |
afterExecute, allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, beforeExecute, execute, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getQueue, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, shutdown, shutdownNow, terminated, toString
public CancelableExecutor(int nThreads)
nThreads
- number of threads in the poolpublic CancelableExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, java.util.concurrent.TimeUnit unit, java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue)
corePoolSize
- same as for super constructormaximumPoolSize
- same as for super constructorkeepAliveTime
- same as for super constructorunit
- same as for super constructorworkQueue
- same as for super constructorThreadPoolExecutor.ThreadPoolExecutor(int, int, long, TimeUnit,
BlockingQueue)
public CancelableExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, java.util.concurrent.TimeUnit unit, java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue, java.util.concurrent.ThreadFactory threadFactory)
corePoolSize
- same as for super constructormaximumPoolSize
- same as for super constructorkeepAliveTime
- same as for super constructorunit
- same as for super constructorworkQueue
- same as for super constructorthreadFactory
- same as for super constructorThreadPoolExecutor.ThreadPoolExecutor(int, int, long, TimeUnit,
BlockingQueue, ThreadFactory)
public CancelableExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, java.util.concurrent.TimeUnit unit, java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue, java.util.concurrent.RejectedExecutionHandler handler)
corePoolSize
- same as for super constructormaximumPoolSize
- same as for super constructorkeepAliveTime
- same as for super constructorunit
- same as for super constructorworkQueue
- same as for super constructorhandler
- same as for super constructorThreadPoolExecutor.ThreadPoolExecutor(int, int, long, TimeUnit,
BlockingQueue, RejectedExecutionHandler)
public CancelableExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, java.util.concurrent.TimeUnit unit, java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue, java.util.concurrent.ThreadFactory threadFactory, java.util.concurrent.RejectedExecutionHandler handler)
corePoolSize
- same as for super constructormaximumPoolSize
- same as for super constructorkeepAliveTime
- same as for super constructorunit
- same as for super constructorworkQueue
- same as for super constructorthreadFactory
- same as for super constructorhandler
- same as for super constructorThreadPoolExecutor.ThreadPoolExecutor(int, int, long, TimeUnit,
BlockingQueue, ThreadFactory, RejectedExecutionHandler)