File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply locked New topic

difference between thread & runnable

laxmidhar prad
Ranch Hand

Joined: Feb 05, 2006
Posts: 33
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
imean to say it is advisable to extend Thread or impliment runnable interface
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63838

Nothing to do with JDBC. Moved.

[Asking smart questions] [About Bear] [Books by Bear]
Henry Wong

Joined: Sep 28, 2004
Posts: 20514

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.


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
I agree. Here's the link:
subject: difference between thread & runnable
It's not a secret anymore!