Why Runnable interface is preferable than extending the Thread class?- Runnable interface is always preferred because, the class implementing it can implement as many interfaces as a developer can, and also extend another class.
- Whereas extending the Thread class, it can not extend another class, as Java supports only single inheritance.
- A thread class can be extended but then any other class cannot be extended.
- If a runnable interface is used the class can be extended which is required other than the thread class.
- The main reason to run an runnable interface is because Java does not support multiple inheritance.
|