Almost all Error subclasses in Java include the "-Error" suffix in their names, but not ThreadDeath. Why is this? This makes it hard to remember if it is a subclass of Error or Exception.
The javadocs for ThreadDeath
say this:
An application should catch instances of this class only if it must clean up after being terminated asynchronously. If
ThreadDeath
is caught by a method, it is important that it be rethrown so that the thread actually dies.
and
The class
ThreadDeath
is specifically a subclass ofError
rather thanException
, even though it is a "normal occurrence", because many applications catch all occurrences ofException
and then discard the exception.
What it is saying is that an application should treat ThreadDeath
differently from both Exception
and (other) Error
classes.
Since the exception should be treated differently, it makes sense to use a class name that doesn't fit the normal patterns.
However, this should be of historic interest anyway. The Thread.stop()
method that throws this was deprecated over 20 years ago. Your code shouldn't use stop()
, and hence should not need to concern itself with this exception. And neither should you.