Thread Class vs Runnable Interface ? To create a Thread we can extends Thread Class or we can implements Runnable Interface , so what is the difference between the two ways ?


1. When we extend the Thread class, we cannot extend any other class because Java doesn’t support multiple inheritance. But, for the case of interfaces, we can implement the Runnable interface, and extend other base classes.

2. By extending Thread class, We can achieve basic functionality of a thread because it provides some inbuilt methods like yield(), interrupt() and other methods… that are not available in Runnable interface !

Read also : How to use Synchronized in Java ? (Example)


  1. Pingback: Multithreading in Java » JavaTuto

Laisser un commentaire