Can anyone explain the differences in the two ways of creating threads beside the fact that when we implement Runnable during thread creation the class can extend some other class which is not possible in case of thread creation by extending the thread class . In what scenario would we prefer creating a thread by implementing the Runnable interface and in which scenario is extending the Thread class preferred .
When we create a thread, JVM does a lot of stuff like initializing the lifecycle of it because thread is not just like any other java object. It is a specialized object which is capable of running on its own. So if you think in this perspective, creating a thread by extending the Thread class is heavy work for the JVM than doing it by passing a Runnable object to existing threads in a pool. So in a concurrent environment it is always recomended to implement Runnable interface than extending a thread.
And ofcourse, another reason is you extend a class only to provide some extra functionality to the super class. If you are not going to create a specialized Thread class by extending it, in the inheritance perspective, its not right.