异步线程池
项目问题:
Caused by: java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.FutureTask@326c8e82 rejected from java.util.concurrent.ThreadPoolExecutor@6e5c35b6[Running, pool size = 200, active threads = 200, queued tasks = 50, completed tasks = 1886]
package cn.async; import java.util.concurrent.Executor; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.annotation.AsyncConfigurer; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; /** * 异步线程池配置类 * @author wangymd * */ @Configuration public class AsyncConfig implements AsyncConfigurer { private Log log = LogFactory.getLog(AsyncConfig.class); @Override @Bean(name = "asyncExecutor") public Executor getAsyncExecutor() { log.info("线程池初始化。。。"); //定义线程池 ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor(); //核心线程数 taskExecutor.setCorePoolSize(50); //线程池最大线程数 taskExecutor.setMaxPoolSize(200); //线程队列最大线程数 taskExecutor.setQueueCapacity(500); //初始化 taskExecutor.initialize(); return taskExecutor; } @Override public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() { // TODO Auto-generated method stub return null; } }