public class ThreadPoolExecutorHandler extends ThreadPoolExecutor
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy| 限定符和类型 | 字段和说明 |
|---|---|
private static long |
KEEP_ALIVE_TIME
线程池维护线程所允许的空闲时间
|
private static org.slf4j.Logger |
log |
private String |
poolName
线程池名称
|
private static int |
QUEUE_CAPACITY
队列最大长度
|
| 构造器和说明 |
|---|
ThreadPoolExecutorHandler(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
@NotNull TimeUnit unit,
@NotNull BlockingQueue<Runnable> workQueue,
String poolName,
RejectedExecutionHandler handler)
初始化线程池
|
ThreadPoolExecutorHandler(String poolName)
初始化线程池
核心数默认为 cpu+1 对列数为 8192 拒绝策略为抛出异常
|
ThreadPoolExecutorHandler(String poolName,
RejectedExecutionHandler handler)
初始化线程池
核心数默认为 cpu+1 对列数为 8192
|
| 限定符和类型 | 方法和说明 |
|---|---|
protected void |
beforeExecute(Thread t,
Runnable r)
打印线程池运行状态
|
afterExecute, allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, 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, toStringinvokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submitprivate final String poolName
private static final long KEEP_ALIVE_TIME
private static final int QUEUE_CAPACITY
private static final org.slf4j.Logger log
public ThreadPoolExecutorHandler(String poolName)
poolName - 线程名称public ThreadPoolExecutorHandler(String poolName, RejectedExecutionHandler handler)
poolName - 线程名称handler - 拒绝策略public ThreadPoolExecutorHandler(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
@NotNull
@NotNull TimeUnit unit,
@NotNull
@NotNull BlockingQueue<Runnable> workQueue,
String poolName,
RejectedExecutionHandler handler)
corePoolSize - 核心数maximumPoolSize - 最大核心数keepAliveTime - 空闲时间unit - 空闲时间单位workQueue - 对列poolName - 线程名称handler - 拒绝策略protected void beforeExecute(Thread t, Runnable r)
beforeExecute 在类中 ThreadPoolExecutort - the thread that will run task rr - the task that will be executedCopyright © 2024. All rights reserved.