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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 19541
    
  16

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: 13870
    
  10

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
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13870
    
  10

Yogesh G - please check your private messages again.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Thread Vs Runnable
 
Similar Threads
run method
Extending Thread or implementing Runnable
why does java have a thread class and a Runnable interface??
Thread/ Runnable
Passing this to a constructor