public class PriorityExecutor extends ThreadPoolExecutor
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy| Constructor and Description |
|---|
PriorityExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
BlockingQueue<Runnable> workQueue)
Creates a new
ThreadPoolExecutor with the given initial
parameters and default thread factory and rejected execution handler. |
PriorityExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
BlockingQueue<Runnable> workQueue,
RejectedExecutionHandler handler)
Creates a new
ThreadPoolExecutor with the given initial
parameters and default thread factory. |
PriorityExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
BlockingQueue<Runnable> workQueue,
ThreadFactory threadFactory)
Creates a new
ThreadPoolExecutor with the given initial
parameters and default rejected execution handler. |
PriorityExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
BlockingQueue<Runnable> workQueue,
ThreadFactory threadFactory,
RejectedExecutionHandler handler)
Creates a new
ThreadPoolExecutor with the given initial
parameters. |
| Modifier and Type | Method and Description |
|---|---|
static ExecutorService |
newFixedThreadPool(int nThreads)
Creates a thread pool that reuses a fixed number of threads
operating off a shared unbounded queue.
|
allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, execute, 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, toStringpublic PriorityExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
BlockingQueue<Runnable> workQueue,
RejectedExecutionHandler handler)
ThreadPoolExecutor with the given initial
parameters and default thread factory.corePoolSize - the number of threads to keep in the pool, even
if they are idle, unless allowCoreThreadTimeOut is setmaximumPoolSize - the maximum number of threads to allow in the
poolkeepAliveTime - when the number of threads is greater than
the core, this is the maximum time that excess idle threads
will wait for new tasks before terminating.unit - the time unit for the keepAliveTime argumentworkQueue - the queue to use for holding tasks before they are
executed. This queue will hold only the Runnable
tasks submitted by the execute method.handler - the handler to use when execution is blocked
because the thread bounds and queue capacities are reachedIllegalArgumentException - if one of the following holds:corePoolSize < 0keepAliveTime < 0maximumPoolSize <= 0maximumPoolSize < corePoolSizeNullPointerException - if workQueue
or handler is nullpublic PriorityExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
BlockingQueue<Runnable> workQueue,
ThreadFactory threadFactory,
RejectedExecutionHandler handler)
ThreadPoolExecutor with the given initial
parameters.corePoolSize - the number of threads to keep in the pool, even
if they are idle, unless allowCoreThreadTimeOut is setmaximumPoolSize - the maximum number of threads to allow in the
poolkeepAliveTime - when the number of threads is greater than
the core, this is the maximum time that excess idle threads
will wait for new tasks before terminating.unit - the time unit for the keepAliveTime argumentworkQueue - the queue to use for holding tasks before they are
executed. This queue will hold only the Runnable
tasks submitted by the execute method.threadFactory - the factory to use when the executor
creates a new threadhandler - the handler to use when execution is blocked
because the thread bounds and queue capacities are reachedIllegalArgumentException - if one of the following holds:corePoolSize < 0keepAliveTime < 0maximumPoolSize <= 0maximumPoolSize < corePoolSizeNullPointerException - if workQueue
or threadFactory or handler is nullpublic PriorityExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
BlockingQueue<Runnable> workQueue,
ThreadFactory threadFactory)
ThreadPoolExecutor with the given initial
parameters and default rejected execution handler.corePoolSize - the number of threads to keep in the pool, even
if they are idle, unless allowCoreThreadTimeOut is setmaximumPoolSize - the maximum number of threads to allow in the
poolkeepAliveTime - when the number of threads is greater than
the core, this is the maximum time that excess idle threads
will wait for new tasks before terminating.unit - the time unit for the keepAliveTime argumentworkQueue - the queue to use for holding tasks before they are
executed. This queue will hold only the Runnable
tasks submitted by the execute method.threadFactory - the factory to use when the executor
creates a new threadIllegalArgumentException - if one of the following holds:corePoolSize < 0keepAliveTime < 0maximumPoolSize <= 0maximumPoolSize < corePoolSizeNullPointerException - if workQueue
or threadFactory is nullpublic PriorityExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
BlockingQueue<Runnable> workQueue)
ThreadPoolExecutor with the given initial
parameters and default thread factory and rejected execution handler.
It may be more convenient to use one of the Executors factory
methods instead of this general purpose constructor.corePoolSize - the number of threads to keep in the pool, even
if they are idle, unless allowCoreThreadTimeOut is setmaximumPoolSize - the maximum number of threads to allow in the
poolkeepAliveTime - when the number of threads is greater than
the core, this is the maximum time that excess idle threads
will wait for new tasks before terminating.unit - the time unit for the keepAliveTime argumentworkQueue - the queue to use for holding tasks before they are
executed. This queue will hold only the Runnable
tasks submitted by the execute method.IllegalArgumentException - if one of the following holds:corePoolSize < 0keepAliveTime < 0maximumPoolSize <= 0maximumPoolSize < corePoolSizeNullPointerException - if workQueue is nullpublic static ExecutorService newFixedThreadPool(int nThreads)
nThreads threads will be active processing tasks.
If additional tasks are submitted when all threads are active,
they will wait in the queue until a thread is available.
If any thread terminates due to a failure during execution
prior to shutdown, a new one will take its place if needed to
execute subsequent tasks. The threads in the pool will exist
until it is explicitly shutdown.nThreads - the number of threads in the poolIllegalArgumentException - if nThreads <= 0Copyright © 2016. All rights reserved.