aspose file tools*
The moose likes Java in General and the fly likes Difference between extends thread class vs  implements runnable interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Difference between extends thread class vs  implements runnable interface" Watch "Difference between extends thread class vs  implements runnable interface" New topic
Author

Difference between extends thread class vs implements runnable interface

Rajendra Prakash
Ranch Hand

Joined: Sep 10, 2009
Posts: 293
Hi Friends, can you give difference between extending thread class and implementing runnable interface.
manoj r patil
Ranch Hand

Joined: Jun 06, 2002
Posts: 181
When you extent from Thread, you inherit all from Thread whereas from Runnable you don't get much but run() method.


love your job and not your company;
...because you never know when your company will stop loving you!
Rajendra Prakash
Ranch Hand

Joined: Sep 10, 2009
Posts: 293
I am not clear . can you explain with other example.
Sebastian Janisch
Ranch Hand

Joined: Feb 23, 2009
Posts: 1183
You most certainly want to implement Runnable rather than extending from Thread. This makes your class more flexible, as you preserve the possibility to extend from another class.


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

Joined: Mar 22, 2005
Posts: 42275
    
  64
That's a FAQ: ExtendingThreadVsImplementingRunnable


Ping & DNS - my free Android networking tools app
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11478
    
  94

Please choose your forum carefully when posting - I have moved this topic to a more appropriate forum.


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Moving to Java.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Difference between extends thread class vs implements runnable interface