我有一台服务器使用在服务器启动时创建的执行服务:
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?附加探查者?调试日志?什么?