简体   繁体   中英

FixedThreadPool and exception while running a thread

I have a FixedThreadPool which has 1 slot for thread execution. Is it possible that, if a thread is occupying the slot and throws a non-catched exception, this slot keeps used forever, and the thread executor is not able to execute any new thread?

No, that's not possible. From the documentation of 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM