各位大神好,在测试该1.0.7版本时,发现个小问题,描述如下:
在使用ThreadPoolBuilder创建DtpExecutor时,设置了preStartAllCoreThreads=true ,期望能提前启动核心线程,代码如下:
ThreadPoolBuilder.newBuilder()
.threadFactory("dtpExecutor1")
.threadPoolName("dtpExecutor1")
.corePoolSize(128)
.maximumPoolSize(256)
.keepAliveTime(60)
.timeUnit(TimeUnit.SECONDS)
.rejectedExecutionHandler("CallerRunsPolicy")
.preStartAllCoreThreads(true)
.workQueue(QueueTypeEnum.VARIABLE_LINKED_BLOCKING_QUEUE.getName(), 128, false)
.buildDynamic();
但由于 DtpExecutor的构造器参数未接收preStartAllCoreThreads参数,导致preStartAllCoreThreads=false无法预启动核心线程。
public DtpExecutor(int corePoolSize,
int maximumPoolSize,
long keepAliveTime,
TimeUnit unit,
BlockingQueue workQueue,
ThreadFactory threadFactory,
RejectedExecutionHandler handler) {
super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory);
this.rejectHandlerName = handler.getClass().getSimpleName();
RejectedExecutionHandler rejectedExecutionHandler = RejectHandlerGetter.getProxy(handler);
setRejectedExecutionHandler(rejectedExecutionHandler);
if (preStartAllCoreThreads) {
prestartAllCoreThreads();
}
}
目前的解决方案是构建好DtpExecutor后,手动调用prestartAllCoreThreads()方法。
这是一款非常不错的开源框架,希望大神们能修复掉这个小BUG,力争成为优秀开源框架。