This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Threads and Synchronization and the fly likes difference between thread & runnable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply locked New topic
Author

difference between thread & runnable

laxmidhar prad
Ranch Hand

Joined: Feb 05, 2006
Posts: 33
sir
sorry,yeserday i asked about advantage of thread class over runnable interface.sir please..
Em Aiy
Ranch Hand

Joined: May 11, 2006
Posts: 226
i can't get are you asking some thing or apologising for asking.

well, i guess you are asking about the difference between Thread and Runnable.

The differnece is that Thread is a class and Runnable is an interface.

You'll prefer to make a thread "Extend" from thread class, if your class is working as thread and you don't want to make any other functionality inherited. but what if you want to make a swing panel working as thread? you have to extend the yourclass from SwingJPanel and from Thread class as well, can you do multiple inheritance?? NO! here you'll use Runnable interface and your class prototype will be like

class YourClass extends JPanel implements Runnable{}


The difference between <b>failure</b> and <b>success</b> is often being <b>right</b> and being <b>exactly right</b>.
laxmidhar prad
Ranch Hand

Joined: Feb 05, 2006
Posts: 33
sir
imean to say it is advisable to extend Thread or impliment runnable interface
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61451
    
  67

Nothing to do with JDBC. Moved.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18916
    
  40

This is another reason why you shouldn't cross post -- you can lose track of where you actually posted the questions to... Anyway, I am going to close this topic, please continue the discussion in this topic.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
 
subject: difference between thread & runnable