我正在使用org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
来执行批处理任务。 (春季软件包的版本为5.1.4.RELEASE
)
这个想法很简单
所以我写得像下面
public void test(){
int start = 1, end = 10000;
int cur = start;
boolean jobLeft = true;
while(jobLeft) {
while(threadPoolTaskExecutor.getActiveCount() < maxThreadPool) {
asyncAnnotationInstance.callMethod(cur);
cur++;
if(cur > end) {
jobLeft = false;
}
}
}
}
但是getActiveCount() < maxThreadPool
语句以某种方式起作用。
我打印错误
org.springframework.core.task.TaskRejectedException: Executor [java.util.concurrent.ThreadPoolExecutor@6c773399[Running, pool size = 20, active threads = 20, queued tasks = 18, completed tasks = 471]] did not accept task: org.springframework.aop.interceptor.AsyncExecutionInterceptor$$Lambda$923/0x000000080076c440@5de11302
我想知道有任何错误,如果有,如何解决。