ThreadPoolExecutor拒绝了错误

时间:2015-02-12 05:48:00

标签: java multithreading

以下错误是什么意思?我怎么能恢复它?

Exception in thread "UserActionProcessor-8811" java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.FutureTask@56624074 rejected from java.util.concurrent.ThreadPoolExecutor@5fd03556[Running, pool size = 300, active threads = 300, queued tasks = 2000, completed tasks = 7979]
        at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2048)
        at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:821)
        at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1372)
        at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:110)

2 个答案:

答案 0 :(得分:2)

您超过了并行运行的最大任务数(300)以及等待开始执行的最大任务数(2000)。您的执行服务无法处理那么多任务,或者提交的任务太耗时。

答案 1 :(得分:1)

这意味着线程池正忙,队列也已满。然后拒绝该任务。如果您不希望任何任务被拒绝,我认为您应该实施拒绝政策。