Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
    Bookmark Topic Watch Topic
  • New Topic

difference between thread & runnable

 
laxmidhar prad
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Report post to moderator
sir
sorry,yeserday i asked about advantage of thread class over runnable interface.sir please..
 
Em Aiy
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Report post to moderator
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{}
 
laxmidhar prad
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Report post to moderator
sir
imean to say it is advisable to extend Thread or impliment runnable interface
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64835
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
Nothing to do with JDBC. Moved.
 
Henry Wong
author
Marshal
Pie
Posts: 21117
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
 
    Bookmark Topic Watch Topic
  • New Topic