解决rejected from java.util.concurrent.ThreadPoolExecutor@29e84858

 

解决方法:

ThreadPoolExecutor executor = new ThreadPoolExecutor(10, 50, 30*1000,TimeUnit.MILLISECONDS, new LinkedBlockingDeque<Runnable>(1000));

使用java.util.concurrent.ThreadPoolExecutor.execute(Runnable command)方法提交任务时,当线程池中正在使用的线程数达到了设置的最大的值(50),而且队列已(1000),就会报错。

 

增加判断即可:executor.getActiveCount()<50时才执行execute方法。

本文链接:http://www.yayihouse.com/yayishuwu/chapter/1578

posted on 2020-03-26 09:51  王子豪  阅读(10316)  评论(0编辑  收藏  举报