我有一个固定线程池,它有 1 个用于线程执行的插槽。是否有可能,如果一个线程正在占用该槽并抛出一个未捕获的异常,则该槽将永远被使用,并且线程执行器无法执行任何新线程?
最佳答案
不,这是不可能的。来自ExecutorService.newFixedThreadPool(int nThreads)
的文档:
If any thread terminates due to a failure during execution prior to shutdown, a new one will take its place if needed to execute subsequent tasks.
关于java - 修复了线程池和运行线程时的异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24261358/