线程池,核心数 10 个,我循环 2 次,等待第一次 10 个线程结束,无法立刻提交第二次的 10 个线程? 同一时刻只会有 10 个线程跑,咋回事啊,大佬指点迷津 提示的 Not completed,难道 call()方法执行完毕,不算一个任务完成吗
代码如图
报错
finished100
finished100
finished100
finished100
finished100
finished100
finished100
finished100
finished100
finished100
finished one repeate
Exception in thread "main" java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.ExecutorCompletionService$QueueingFuture@48140564[Not completed, task = java.util.concurrent.Executors$RunnableAdapter@7c30a502[Wrapped task = java.util.concurrent.FutureTask@1d251891[Not completed, task = executor.ExecutorDemo$1@49e4cb85]]] rejected from java.util.concurrent.ThreadPoolExecutor@2133c8f8[Running, pool size = 10, active threads = 2, queued tasks = 0, completed tasks = 10]
at java.base/java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2055)
at java.base/java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:825)
at java.base/java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1355)
at java.base/java.util.concurrent.ExecutorCompletionService.submit(ExecutorCompletionService.java:184)
at executor.ExecutorDemo.main(ExecutorDemo.java:34)
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.