public class FifoPriorityThreadPoolExecutor extends ThreadPoolExecutor
ThreadPoolExecutor
that prioritizes submitted Runnable
s by assuming they implement
Prioritized
. Prioritized
runnables that return lower values for Prioritized.getPriority()
will be executed before those that return higher values. Priorities only apply when multiple items are queued at the
same time. Runnables with the same priority will be executed in FIFO order.Modifier and Type | Class and Description |
---|---|
static class |
FifoPriorityThreadPoolExecutor.DefaultThreadFactory
A
ThreadFactory that builds threads with priority
Process.THREAD_PRIORITY_BACKGROUND . |
static class |
FifoPriorityThreadPoolExecutor.UncaughtThrowableStrategy
A strategy for handling unexpected and uncaught throwables thrown by futures run on the pool.
|
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy
Constructor and Description |
---|
FifoPriorityThreadPoolExecutor(int poolSize)
Constructor to build a fixed thread pool with the given pool size using
FifoPriorityThreadPoolExecutor.DefaultThreadFactory . |
FifoPriorityThreadPoolExecutor(int poolSize,
FifoPriorityThreadPoolExecutor.UncaughtThrowableStrategy uncaughtThrowableStrategy)
Constructor to build a fixed thread pool with the given pool size using
FifoPriorityThreadPoolExecutor.DefaultThreadFactory . |
FifoPriorityThreadPoolExecutor(int corePoolSize,
int maximumPoolSize,
long keepAlive,
TimeUnit timeUnit,
ThreadFactory threadFactory,
FifoPriorityThreadPoolExecutor.UncaughtThrowableStrategy uncaughtThrowableStrategy) |
Modifier and Type | Method and Description |
---|---|
protected void |
afterExecute(Runnable r,
Throwable t) |
protected <T> RunnableFuture<T> |
newTaskFor(Runnable runnable,
T value) |
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
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, submit, submit, submit
public FifoPriorityThreadPoolExecutor(int poolSize)
FifoPriorityThreadPoolExecutor.DefaultThreadFactory
.poolSize
- The number of threads.public FifoPriorityThreadPoolExecutor(int poolSize, FifoPriorityThreadPoolExecutor.UncaughtThrowableStrategy uncaughtThrowableStrategy)
FifoPriorityThreadPoolExecutor.DefaultThreadFactory
.poolSize
- The number of threads.uncaughtThrowableStrategy
- Dictates how the pool should handle uncaught and unexpected throwables
thrown by Futures run by the pool.public FifoPriorityThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAlive, TimeUnit timeUnit, ThreadFactory threadFactory, FifoPriorityThreadPoolExecutor.UncaughtThrowableStrategy uncaughtThrowableStrategy)
protected <T> RunnableFuture<T> newTaskFor(Runnable runnable, T value)
newTaskFor
in class AbstractExecutorService
protected void afterExecute(Runnable r, Throwable t)
afterExecute
in class ThreadPoolExecutor