Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
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 Murach's Java Servlets and JSP this week in the Servlets 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: 41040
    
  43
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: 41040
    
  43
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
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