Package cn.sinozg.applet.common.handler
Class ThreadPoolExecutorHandler
java.lang.Object
java.util.concurrent.AbstractExecutorService
java.util.concurrent.ThreadPoolExecutor
cn.sinozg.applet.common.handler.ThreadPoolExecutorHandler
- All Implemented Interfaces:
Executor,ExecutorService
重写线程池 打印当前的线程信息
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final long线程池维护线程所允许的空闲时间private static final org.slf4j.Loggerprivate final String线程池名称private static final int队列最大长度 -
Constructor Summary
ConstructorsConstructorDescriptionThreadPoolExecutorHandler(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 -
Method Summary
Methods inherited from class java.util.concurrent.ThreadPoolExecutor
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, toStringMethods inherited from class java.util.concurrent.AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
-
Field Details
-
poolName
线程池名称 -
KEEP_ALIVE_TIME
private static final long KEEP_ALIVE_TIME线程池维护线程所允许的空闲时间- See Also:
-
QUEUE_CAPACITY
private static final int QUEUE_CAPACITY队列最大长度- See Also:
-
log
private static final org.slf4j.Logger log
-
-
Constructor Details
-
ThreadPoolExecutorHandler
初始化线程池 核心数默认为 cpu+1 对列数为 8192 拒绝策略为抛出异常- Parameters:
poolName- 线程名称
-
ThreadPoolExecutorHandler
初始化线程池 核心数默认为 cpu+1 对列数为 8192- Parameters:
poolName- 线程名称handler- 拒绝策略
-
ThreadPoolExecutorHandler
public ThreadPoolExecutorHandler(int corePoolSize, int maximumPoolSize, long keepAliveTime, @NotNull @NotNull TimeUnit unit, @NotNull @NotNull BlockingQueue<Runnable> workQueue, String poolName, RejectedExecutionHandler handler) 初始化线程池- Parameters:
corePoolSize- 核心数maximumPoolSize- 最大核心数keepAliveTime- 空闲时间unit- 空闲时间单位workQueue- 对列poolName- 线程名称handler- 拒绝策略
-
-
Method Details
-
beforeExecute
打印线程池运行状态- Overrides:
beforeExecutein classThreadPoolExecutor- Parameters:
t- the thread that will run taskrr- the task that will be executed
-