问题:ThreadPoolExecutor提交过多会报RejectedExecutionException

...发布 问题来源
``` public class executor { public static void main(String[] args) {// ExecutorService executorService = Executors.newFixedThreadPool(6);// ExecutorService executorService = Executors.newCachedThreadPool(); ExecutorService executorService = new ThreadPoolExecutor(4, 8, 60L, TimeUnit.SECONDS, new SynchronousQueue<>()); for (int i = 0; i < 10; i++) { String name = Integer.toString(i); executorService.submit(() -> { System.out.println("start task " + name); try { Thread.sleep(1000); } catch (InterruptedException e) { } System.out.println("end task " + name); }); } executorService.shutdown(); }} ```
  • 1

您当前正在使用不支持HTML5的低版本浏览器,飞扬学院需要支持HTML5的浏览器才能为您提供更好的学习体验。请使用支持HTML5的Chrome浏览器Firefox浏览器或最新版本的IE浏览器