What causes ThreadDeath to happen? I've noticed that Thread.sleep() invokes them somehow. But why? How to avoid them?
John Zukowski ThreadDeath is a special Java error that is caught by the runtime system to free system resources used by a thread. You can't stop / avoid them. In fact, if you catch them and don't rethrow them, your JVM won't continue to run well for long.
The runtime throws them to signal the 'death' of a thread, usually because the run() method finished or because an unchecked interrupt was thrown.