Quantcast
Channel: "implements Runnable" vs "extends Thread" in Java - Stack Overflow
Viewing all articles
Browse latest Browse all 45

Answer by Nikhil A A for "implements Runnable" vs "extends Thread" in Java

$
0
0

One reason you'd want to implement an interface rather than extend a base class is that you are already extending some other class. You can only extend one class, but you can implement any number of interfaces.

If you extend Thread, you're basically preventing your logic to be executed by any other thread than 'this'. If you only want some thread to execute your logic, it's better to just implement Runnable.


Viewing all articles
Browse latest Browse all 45

Trending Articles