why isn't Thread class final? Why would you extend a Thread ever?
java, multithreading
Solution
From Oracle's documentation:
There are two ways to create a new thread of execution. One is to declare a class to be a subclass of Thread. This subclass should override the run method of class Thread. The other way to create a thread is to declare a class that implements the Runnable interface.
So the answer is "you may want to subclass `Thread` to override its `run()` method."
The quoted paragraphs have been in the Java documentation going back as far as JDK 1.1. Java has added other convenient classes for managing concurrency, most notably, the executors mentioned in the comments, possibly diminishing or eliminating the need to extend `Thread`. They cannot make it `final`, however, because that would break backward compatibility.
As far as practical reasons go, I think the only reason you may want to extend `Thread` rather than implement `Runnable` today would be to override its methods other than `run()`. For example, you may want to add logging or additional clean-up.
Problem
I got this as an interview question. why isn't Thread class final? Why would you extend a Thread ever? I could not come up with real world use cases.