aspose file tools*
The moose likes Threads and Synchronization and the fly likes Thread vs Runnable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Thread vs Runnable " Watch "Thread vs Runnable " New topic
Author

Thread vs Runnable

vijay kumar
Ranch Hand

Joined: Nov 05, 2005
Posts: 58
Is there any other differences between Implementing Runnable interface and Thread class apart from OO opttion.
Saket Barve
Ranch Hand

Joined: Dec 19, 2002
Posts: 229
Functionality wise, no.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12823
    
    5
If you extend Thread, each instance will automatically have a reference in a ThreadGroup - this has some implications for locating instances of your class and other stuff. See the java.lang.ThreadGroup JavaDocs.
Bill
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
It's been noted many times that it was probably a mistake for Thread to
implement Runnable: it confuses the task with the worker. Since one
almost never overrides Thread methods other than run, keep it simple
and implement Runnable and then use Thread without subclassing:
How bad is it that Thread implements Runnable? At another Java site,
I saw some nasty code where someone tried to "restart" a thread like
this:


There is no emoticon for what I am feeling!
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Moving to "Threads and Synchronization."


[Jess in Action][AskingGoodQuestions]
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
You might be interested in this thread.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Thread vs Runnable