RejctedExecutionException的原因是什么?(What are the causes of RejctedExecutionException?)

除了先前在Executor上调用shutdown()之外还有其他原因引发RejectedExecutionException(我使用的是singleThreadExecutor)吗? 我有一些崩溃报告如下。 它们非常罕见,我无法在我的设备上重现。 我的代码太复杂而无法发布,但我没有看到在调用shutdown()之后提交任何任务的逻辑可行性。

有没有其他原因可以抛出RejectedExecutionException?

java.util.concurrent.RejectedExecutionException:从java.util.concurrent.ThreadPoolExecutor@41a36e90拒绝的任务java.util.concurrent.FutureTask@4194a5f0 [已终止,池大小= 0,活动线程= 0,排队任务= 0,已完成任务= 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)java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:81)at java.util.concurrent.Executors $ DelegatedExecutorService.submit(Executors.java:562)at com.smp.soundtouchandroid.AACFileAudioSink。在com.smp.soundtouchandroidSoundStreamRunnable的com.smp.soundtouchandroid.SoundStreamRunnable.processChunk(SoundStreamRunnable.java:406)的com.smp.soundtouchandroid.SoundStreamRunnable.processFunk(SoundStreamRunnable.java:406)上编写(AACFileAudioSink.java:28) .RUN(所以 undStreamRunnable.java:223)在java.lang.Thread.run(Thread.java:856)

Are there any other causes for RejectedExecutionException being thrown besides shutdown() being called previously on the Executor (I'm using a singleThreadExecutor)? I have some crash reports as below. They are very rare and I can't reproduce on my devices. My code is too complex to post, but I'm not seeing how it's logically possible that any tasks are being submitted after shutdown() is called.

Are there any other reasons that RejectedExecutionException could be thrown here?

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具有有限数量的线程,或者工作队列具有有限容量并且已满(例如,传递给ThreadPoolExecutor构造函数的有限容量的LinkedBlockingQueue)。

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

Your ThreadPoolExecutor is shutdown, or

ThreadPoolExecutor has a finite number of threads, or work queue has finite capacity and is full (e.g., LinkedBlockingQueue of finite capacity passed in to ThreadPoolExecutor constructor).

更多推荐