aspose file tools*
The moose likes Java in General and the fly likes Thread Vs Runnable 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 "Thread Vs Runnable" Watch "Thread Vs Runnable" New topic
Author

Thread Vs Runnable

Rohit Kumar
Ranch Hand

Joined: Sep 20, 2007
Posts: 53
What is difference between extending thread class and implementing Runnable interface.
Any differnce rather than extends single class and implemet multiple interface?

Regards,
yogesh
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
Please search the Beginner forum for the many threads in which this has already been discussed.


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19722
    
  20

When you implement Runnable you can re-run the same logic in another thread if needed.
If you extends Thread then you can only start() it once.

That'd be the main reason for using Runnables.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14270
    
  21

Yogesh, please check your private messages. You can see them by clicking My Private Messages.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14270
    
  21

Yogesh G - please check your private messages again.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Thread Vs Runnable