If we want to create thread then we extend Thread class or Implement Runnable interface Why we have two seperate option to creat a Thread Is there any special reason behind it?
When we use Thread Class and When we use Runnable Interface
Please anyone help me.
posted 10 years ago
One technical cause is that Java does not support multiple inheritance. You cannot extend Thread when your class is already extending another. Another situation is when one who maintains the thread and one who provides the functionality are different � something like a generic thread pool.
One more reason is the coding style itself. People say if you "extend" a class you should be "adding" one or more functionalities to it. Such go for Runnable approach if the need is just to implement run() method.