public class MilkyThreadPoolExecutor extends ThreadPoolExecutor
| Modifier and Type | Class and Description |
|---|---|
static interface |
MilkyThreadPoolExecutor.ShutdownListener |
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy| Constructor and Description |
|---|
MilkyThreadPoolExecutor(String name,
ThreadContext threadContext,
int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
BlockingQueue<Runnable> workQueue) |
MilkyThreadPoolExecutor(String name,
ThreadContext threadContext,
int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
BlockingQueue<Runnable> workQueue,
ThreadFactory threadFactory) |
MilkyThreadPoolExecutor(String name,
ThreadContext threadContext,
int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
BlockingQueue<Runnable> workQueue,
ThreadFactory threadFactory,
XRejectedExecutionHandler handler) |
MilkyThreadPoolExecutor(String name,
ThreadContext threadContext,
int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
BlockingQueue<Runnable> workQueue,
XRejectedExecutionHandler handler) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
afterExecute(Runnable r,
Throwable t) |
protected void |
appendThreadPoolExecutorDetails(StringBuilder sb)
Append details about this thread pool to the specified
StringBuilder. |
protected void |
beforeExecute(Thread t,
Runnable r)
todo thread context
|
protected void |
cancelRemainingTask(Runnable task)
Cancel the given remaining task which never commended execution,
as returned from
ExecutorService.shutdownNow(). |
void |
execute(Runnable command) |
String |
getName() |
void |
setAwaitTerminationMillis(long awaitTerminationMillis) |
void |
setWaitForTasksToCompleteOnShutdown(boolean waitForJobsToCompleteOnShutdown)
Set whether to wait for scheduled tasks to complete on shutdown,
not interrupting running tasks and executing all tasks in the queue.
|
void |
shutdown() |
protected void |
terminated() |
String |
toString() |
allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getQueue, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, shutdownNowinvokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submitpublic MilkyThreadPoolExecutor(String name, ThreadContext threadContext, int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue)
public MilkyThreadPoolExecutor(String name, ThreadContext threadContext, int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory)
public MilkyThreadPoolExecutor(String name, ThreadContext threadContext, int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, XRejectedExecutionHandler handler)
public MilkyThreadPoolExecutor(String name, ThreadContext threadContext, int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory, XRejectedExecutionHandler handler)
public final String getName()
public void setWaitForTasksToCompleteOnShutdown(boolean waitForJobsToCompleteOnShutdown)
Default is "false", shutting down immediately through interrupting ongoing tasks and clearing the queue. Switch this flag to "true" if you prefer fully completed tasks at the expense of a longer shutdown phase.
Note that Spring's container shutdown continues while ongoing tasks
are being completed. If you want this executor to block and wait for the
termination of tasks before the rest of the container continues to shut
down - e.g. in order to keep up other resources that your tasks may need -,
set the "awaitTerminationSeconds"
property instead of or in addition to this property.
public void setAwaitTerminationMillis(long awaitTerminationMillis)
protected void beforeExecute(Thread t, Runnable r)
beforeExecute in class ThreadPoolExecutorpublic void execute(Runnable command)
execute in interface Executorexecute in class ThreadPoolExecutorprotected void afterExecute(Runnable r, Throwable t)
afterExecute in class ThreadPoolExecutorprotected void terminated()
terminated in class ThreadPoolExecutorpublic final String toString()
toString in class ThreadPoolExecutorprotected void appendThreadPoolExecutorDetails(StringBuilder sb)
StringBuilder. All details should be appended as key/value pairs in
the form "%s = %s, "sb - the StringBuilder to append topublic void shutdown()
shutdown in interface ExecutorServiceshutdown in class ThreadPoolExecutorprotected void cancelRemainingTask(Runnable task)
ExecutorService.shutdownNow().task - the task to cancel (typically a RunnableFuture)Copyright © 2022. All rights reserved.