码迷,mamicode.com
首页 > 编程语言 > 详细

异步线程池

时间:2019-09-11 09:39:44      阅读:104      评论:0      收藏:0      [点我收藏+]

标签:public   aop   aci   let   over   common   text   etl   exce   

项目问题:

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;
    }

}

 

异步线程池

标签:public   aop   aci   let   over   common   text   etl   exce   

原文地址:https://www.cnblogs.com/wangymd/p/11490507.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!