public class ThreadPool extends Object
Modifier and Type | Field and Description |
---|---|
protected static int |
MAX_POOL_SIZE |
protected static int |
maxPoolSize |
protected static int |
MIN_POOL_SIZE |
protected static int |
minPoolSize |
protected static int |
STATUS_INTERVAL |
protected static ConcurrentHashMap<String,ThreadPoolExecutor> |
THREAD_POOL_HANDLER |
Modifier and Type | Method and Description |
---|---|
static ThreadPoolExecutor |
createThreadPool(String poolName)
使用默认配置构造线程池, 配置来自于 fraemwork.properties
|
static ThreadPoolExecutor |
createThreadPool(String poolName,
int mimPoolSize,
int maxPoolSize,
int keepAliveTime)
创建线程池
|
static ThreadPoolExecutor |
createThreadPool(String poolName,
int mimPoolSize,
int maxPoolSize,
int keepAliveTime,
boolean daemon,
int priority)
创建线程池
|
static ThreadPoolExecutor |
createThreadPool(String poolName,
int mimPoolSize,
int maxPoolSize,
int keepAliveTime,
boolean daemon,
int priority,
int queueSize)
创建线程池
|
static int |
getMaxPoolSize()
获取线程池最大活动线程数
|
static int |
getMinPoolSize()
获取线程池最小活动线程数
|
static int |
getStatusInterval()
获取线程池最大活动线程数
|
static void |
gracefulShutdown(ThreadPoolExecutor threadPoolExecutor)
平滑的关闭线程池
|
protected static int MIN_POOL_SIZE
protected static int MAX_POOL_SIZE
protected static int STATUS_INTERVAL
protected static int minPoolSize
protected static int maxPoolSize
protected static ConcurrentHashMap<String,ThreadPoolExecutor> THREAD_POOL_HANDLER
public static int getMinPoolSize()
public static int getMaxPoolSize()
public static int getStatusInterval()
public static ThreadPoolExecutor createThreadPool(String poolName)
poolName
- 线程池名称public static ThreadPoolExecutor createThreadPool(String poolName, int mimPoolSize, int maxPoolSize, int keepAliveTime)
poolName
- 池的名称mimPoolSize
- 最小线程数maxPoolSize
- 最大线程数keepAliveTime
- 线程闲置最大存活时间,单位: 毫秒public static ThreadPoolExecutor createThreadPool(String poolName, int mimPoolSize, int maxPoolSize, int keepAliveTime, boolean daemon, int priority)
poolName
- 池的名称mimPoolSize
- 最小线程数maxPoolSize
- 最大线程数keepAliveTime
- 线程闲置最大存活时间, 单位: 毫秒daemon
- 是否是守护线程priority
- 线程优先级public static ThreadPoolExecutor createThreadPool(String poolName, int mimPoolSize, int maxPoolSize, int keepAliveTime, boolean daemon, int priority, int queueSize)
poolName
- 池的名称mimPoolSize
- 最小线程数maxPoolSize
- 最大线程数keepAliveTime
- 线程闲置最大存活时间, 单位: 毫秒daemon
- 是否是守护线程priority
- 线程优先级queueSize
- 线程池任务队列大小public static void gracefulShutdown(ThreadPoolExecutor threadPoolExecutor)
threadPoolExecutor
- 线程池对象Copyright © 2020 Voovan. All rights reserved.