aspose file tools
The moose likes Java in General and the fly likes Thread Vs Runnable Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply 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.<br /> <br />#:^P
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19232

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
How To Ask Questions How To Answer Questions
Jesper de Jong
Java Cowboy
Bartender

Joined: Aug 16, 2005
Posts: 12953
    
    3

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 7 API documentation
Scala Notes - My blog about Scala
Jesper de Jong
Java Cowboy
Bartender

Joined: Aug 16, 2005
Posts: 12953
    
    3

Yogesh G - please check your private messages again.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Thread Vs Runnable
 
Similar Threads
run method
Thread/ Runnable
Extending Thread or implementing Runnable
Passing this to a constructor
why does java have a thread class and a Runnable interface??