public class ThreadPoolCreator extends Object
| 限定符和类型 | 方法和说明 |
|---|---|
static ThreadPoolExecutor |
createCommonFast(String threadPrefix) |
static ExecutorService |
createCommonWithTtl(String threadPrefix) |
static DtpExecutor |
createDynamicFast(String poolName) |
static DtpExecutor |
createDynamicFast(String poolName,
String threadPrefix) |
static ExecutorService |
createDynamicWithTtl(String poolName) |
static ExecutorService |
createDynamicWithTtl(String poolName,
String threadPrefix) |
static ExecutorService |
newCachedThreadPool(String threadPrefix,
int maximumPoolSize) |
static ThreadPoolExecutor |
newExecutorByBlockingCoefficient(float blockingCoefficient)
阻塞系数 = 阻塞时间/(阻塞时间+使用CPU的时间)
建议线程数 = CPU可用核心数 / (1 - 阻塞系数)
计算密集型任务的阻塞系数为0,而IO密集型任务的阻塞系数则接近于1
|
static ThreadPoolExecutor |
newFixedThreadPool(String threadPrefix,
int poolSize,
int queueCapacity) |
static ThreadPoolExecutor |
newSingleThreadPool(String threadPrefix,
int queueCapacity) |
static ThreadPoolExecutor |
newThreadPool(String threadPrefix,
int corePoolSize,
int maximumPoolSize,
int queueCapacity) |
public static ThreadPoolExecutor createCommonFast(String threadPrefix)
public static ExecutorService createCommonWithTtl(String threadPrefix)
public static DtpExecutor createDynamicFast(String poolName)
public static DtpExecutor createDynamicFast(String poolName, String threadPrefix)
public static ExecutorService createDynamicWithTtl(String poolName)
public static ExecutorService createDynamicWithTtl(String poolName, String threadPrefix)
public static ThreadPoolExecutor newSingleThreadPool(String threadPrefix, int queueCapacity)
public static ThreadPoolExecutor newFixedThreadPool(String threadPrefix, int poolSize, int queueCapacity)
public static ExecutorService newCachedThreadPool(String threadPrefix, int maximumPoolSize)
public static ThreadPoolExecutor newThreadPool(String threadPrefix, int corePoolSize, int maximumPoolSize, int queueCapacity)
public static ThreadPoolExecutor newExecutorByBlockingCoefficient(float blockingCoefficient)
blockingCoefficient - 阻塞系数,阻塞因子介于0~1之间的数,阻塞因子越大,线程池中的线程数越多ThreadPoolExecutorCopyright © 2023. All rights reserved.