I have a java.util.concurrent.Execution service - a single threaded thread pool executor. I submit certain tasks to it. If the task throws an unchecked exception the thread dies but the service ensures that a new thread is spawned and subsequent tasks are performed in that. However I do not want this feature and still want to use a threadPoolExecutor. i.e. I want the service to shutDownNow() if the task throws an unchecked exception.
What is the best way to achieve this? Would using a custom thread factory which restricts the number of threads spawned make good sense?