File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Threads and Synchronization and the fly likes extends Thread  Vs  implements Runnable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "extends Thread  Vs  implements Runnable" Watch "extends Thread  Vs  implements Runnable" New topic

extends Thread Vs implements Runnable

kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1427
Both are implementing run() method. If i choose Runnable interface, supports multiple interface inheritance. Why do we need Thread class ?
Sebastian Janisch
Ranch Hand

Joined: Feb 23, 2009
Posts: 1183
If you implement Runnable you still have to pass your class to a Thread if you want to start it. Following the 'Favor Composition Over Inheritance' you most likely are always better off implementing Runnable than extending Thread.

JDBCSupport - An easy to use, light-weight JDBC framework -
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
This may help:
I agree. Here's the link:
subject: extends Thread Vs implements Runnable
It's not a secret anymore!