Quantcast
Viewing latest article 5
Browse Latest Browse All 45

Answer by Pritam Banerjee for "implements Runnable" vs "extends Thread" in Java

Thread class defines several methods that can be overriden by the the extending class. But to create a thread we must override the run() method. Same applies to Runnable as well.

However Runnable is a preferred method of creating a thread. The primary reasons are:

  1. Since Runnable is an interface, you can extend other classes. But if you extend Thread then that option is gone.

  2. If you are not modifying or enhancing a whole lot of Thread functionalities and extending the Thread class is not a preferred way.


Viewing latest article 5
Browse Latest Browse All 45

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>