This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Threads and Synchronization and the fly likes Runnable Interface VS Thread Class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Runnable Interface VS Thread Class" Watch "Runnable Interface VS Thread Class" New topic
Author

Runnable Interface VS Thread Class

rakesh kumar nampally
Ranch Hand

Joined: Feb 03, 2007
Posts: 46
Hi,

I heard that implementing Runnable Interface is more advantageous when compare to extending Thread class, can any one please explain the advantages and disadvantages of these both.

thanks,
rakesh.


thanks & regards, Rakesh
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41150
    
  45
Welcome to JavaRanch.

There's a lengthy writeup in the FAQ: ExtendingThreadVsImplementingRunnable


Ping & DNS - my free Android networking tools app
rakesh kumar nampally
Ranch Hand

Joined: Feb 03, 2007
Posts: 46
Thank You for a quick response.
rakesh kumar nampally
Ranch Hand

Joined: Feb 03, 2007
Posts: 46
But i heard that if you want make use of all thread methods then go for extending Thread class else if you want to implement only run() method then use Runnable interface. How far this is true.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41150
    
  45
It is true, but that doesn't contradict what the FAQ entry says.
rakesh kumar nampally
Ranch Hand

Joined: Feb 03, 2007
Posts: 46
Thank You
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Runnable Interface VS Thread Class
 
Similar Threads
run method
Passing this to a constructor
why does java have a thread class and a Runnable interface??
Extending Thread or implementing Runnable
Thread/ Runnable