gpt4 book ai didi

java - 谁在关闭我的执行者?

转载 作者:搜寻专家 更新时间:2023-11-01 03:25:46 26 4
gpt4 key购买 nike

我有一个使用在服务器启动时创建的执行服务的服务器:

simpleExecutorService = Executors.newFixedThreadPool(nThreads, new MyThreadFactory(threadFactoryName));

然后我使用执行器服务实例来执行一些任务。但过了一会儿(30 分钟左右)我明白了:

java.util.concurrent.RejectedExecutionException
at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:1768)

我读过 here当执行程序关闭时可能会发生这种情况。我从来没有关闭它,所以这怎么会发生?关于如何调试此类问题的任何想法?

最佳答案

从您链接到的同一页面:

New tasks submitted in method execute(java.lang.Runnable) will be rejected when the Executor has been shut down, and also when the Executor uses finite bounds for both maximum threads and work queue capacity, and is saturated.

那么也许工作队列已满并且线程数已达到最大值?

您是否了解它在做什么?通过 JMX?附加分析器?调试日志?有什么事吗?

关于java - 谁在关闭我的执行者?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14243127/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com