Why does java ThreadPoolExecutor kill the thread when a RuntimeException is thrown?
This is the same as Why does java ThreadPoolExecutor kill the thread when a RuntimeException is thrown? but there is no broad acceptable answer.
In the "Workflow" method
/**
* Main run loop
*/
public void run() {
try {
Runnable task = firstTask;
firstTask = null;
while (task != null || (task = getTask()) != null) {
runTask(task);
task = null;
}
} finally {
workerDone(this);
}
}
Why not just catch the RuntimeException in the while loop so that the worker continues the loop?
ps: I am using Java 6 on Mac. Java 8 makes some changes, but no different mechanism.
+3
source to share
No one has answered this question yet
See similar questions:
or similar: