public static class ThreadPoolConfig.Config
extends java.lang.Object
| 限定符和类型 | 字段和说明 |
|---|---|
static int |
DEFAULT_CORE_POOL_SIZE
核心线程数 8
|
static long |
DEFAULT_KEEPALIVE_TIME
当线程数大于核心时,此为终止前多余的空闲线程等待新任务的最长时间。
|
static int |
DEFAULT_MAXIMUM_POOL_SIZE
线程池大小 40
|
static int |
DEFAULT_QUEUE_SIZE
队例大小 20000
|
| 构造器和说明 |
|---|
Config() |
| 限定符和类型 | 方法和说明 |
|---|---|
java.util.concurrent.ThreadPoolExecutor |
build() |
protected void |
checkArgument() |
ThreadPoolConfig.Config |
corePoolSize(int corePoolSize)
核心线程数
|
protected java.util.concurrent.BlockingQueue<java.lang.Runnable> |
createQueue(java.lang.Integer size)
创建默认队列
|
protected java.util.concurrent.ThreadFactory |
getThreadFactory(java.lang.String name)
创建默认线程工厂类
|
ThreadPoolConfig.Config |
handler(java.util.concurrent.RejectedExecutionHandler handler)
Set RejectedExecutionHandler
|
ThreadPoolConfig.Config |
keepAliveTime(long keepAliveTime)
ThreadPoolExecutor的keepAliveTime=0时,表示超过core线程数的线程在空闲时立即结束
|
ThreadPoolConfig.Config |
maximumPoolSize(int maximumPoolSize)
有界队列。
|
ThreadPoolConfig.Config |
name(java.lang.String name)
设置线程名称
|
protected java.util.concurrent.ThreadPoolExecutor |
newThreadPool()
创建线程池 判断handler是否为空
|
ThreadPoolConfig.Config |
queue(java.util.concurrent.BlockingQueue<java.lang.Runnable> queue)
设置队列
|
ThreadPoolConfig.Config |
queueSize(int queueSize)
排队的等待数量
|
ThreadPoolConfig.Config |
threadFactory(java.util.concurrent.ThreadFactory threadFactory)
线程工厂,提供创建新线程的功能。
|
ThreadPoolConfig.Config |
timeUnit(java.util.concurrent.TimeUnit timeUnit)
设置TimeUnit
|
public static final int DEFAULT_CORE_POOL_SIZE
public static final int DEFAULT_QUEUE_SIZE
public static final int DEFAULT_MAXIMUM_POOL_SIZE
public static final long DEFAULT_KEEPALIVE_TIME
public ThreadPoolConfig.Config threadFactory(java.util.concurrent.ThreadFactory threadFactory)
threadFactory - ThreadFactorypublic ThreadPoolConfig.Config handler(java.util.concurrent.RejectedExecutionHandler handler)
handler - RejectedExecutionHandlerpublic ThreadPoolConfig.Config timeUnit(java.util.concurrent.TimeUnit timeUnit)
timeUnit - TimeUnitpublic ThreadPoolConfig.Config corePoolSize(int corePoolSize)
corePoolSize - Configpublic ThreadPoolConfig.Config maximumPoolSize(int maximumPoolSize)
maximumPoolSize - 有界队列public ThreadPoolConfig.Config keepAliveTime(long keepAliveTime)
keepAliveTime - 默认值为0public ThreadPoolConfig.Config name(java.lang.String name)
name - 线程名称public ThreadPoolConfig.Config queue(java.util.concurrent.BlockingQueue<java.lang.Runnable> queue)
queue - BlockingQueuepublic ThreadPoolConfig.Config queueSize(int queueSize)
queueSize - protected java.util.concurrent.ThreadFactory getThreadFactory(java.lang.String name)
name - 线程名称 ,如果线程池名称为空,会生成随时数protected java.util.concurrent.BlockingQueue<java.lang.Runnable> createQueue(java.lang.Integer size)
size - 队列protected java.util.concurrent.ThreadPoolExecutor newThreadPool()
protected void checkArgument()
public java.util.concurrent.ThreadPoolExecutor build()