是否有任何情况下 ThreadPoolExecutor.CallerRunsPolicy会抛出 RejectedExecutionException ?
在我看来,政策本身就是为了防止抛出这些异常。其接口(interface)方法的 API,RejectedExecutionHandler.rejectedExecution()声称它可能会抛出 RejectedExecutionException
. CallerRunsPolicy.rejectedExecution() 的 API 没有。
总结:我需要显式处理 RejectedExecutionException
吗?在 execute()
如果我使用 CallerRunsPolicy
?
最佳答案
不,你不知道。 ThreadPoolExecutor.CallerRunsPolicy 永远不会抛出 RejectedExecutionException
除非你在 Runnable#run
关于java - ThreadPoolExecutor.CallerRunsPolicy 会抛出 RejectedExecutionException 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3737004/