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


解決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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM