gpt4 book ai didi

java - RejectedExecutionException 的原因是什么?

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:24:39 24 4
gpt4 key购买 nike

除了先前在 Executor 上调用的 shutdown() 之外,是否还有其他原因导致 RejectedExecutionException 被抛出(我使用的是 singleThreadExecutor)?我有一些崩溃报告如下。它们非常罕见,我无法在我的设备上复制。我的代码太复杂而无法发布,但我看不出在调用 shutdown() 之后提交任何任务在逻辑上是如何可能的。

是否还有其他原因可以在此处抛出 RejectedExecutionException?

java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.FutureTask@4194a5f0 rejected from java.util.concurrent.ThreadPoolExecutor@41a36e90[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 9813] at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:1979) at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:786) at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1307) at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:81) at java.util.concurrent.Executors$DelegatedExecutorService.submit(Executors.java:562) at com.smp.soundtouchandroid.AACFileAudioSink.write(AACFileAudioSink.java:28) at com.smp.soundtouchandroid.SoundStreamRunnable.processChunk(SoundStreamRunnable.java:469) at com.smp.soundtouchandroid.SoundStreamRunnable.processFile(SoundStreamRunnable.java:406) at com.smp.soundtouchandroid.SoundStreamRunnable.run(SoundStreamRunnable.java:223) at java.lang.Thread.run(Thread.java:856)

最佳答案

参见 http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ThreadPoolExecutor.html

您的 ThreadPoolExecutor 已关闭,或者

ThreadPoolExecutor 的线程数量有限,或者工作队列容量有限且已满(例如,有限容量的 LinkedBlockingQueue 传递给 ThreadPoolExecutor 构造函数)。

关于java - RejectedExecutionException 的原因是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26189109/

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