Why its better to implement class with runnable instead of extending Thread class?

Questions by singhreshu   answers by singhreshu

Showing Answers 1 - 16 of 16 Answers

SaiSatish

  • Oct 26th, 2006
 

Because.........

if we use extends we can only extend only Thread and it is not possible to extend some more classes . . .if we use implements Runnable then we can implement as many as interfaces...

  Was this answer useful?  Yes

Natarajan

  • Oct 26th, 2006
 

To provide multiple inheritance

  Was this answer useful?  Yes

Lavanya

  • Oct 27th, 2006
 

bcz if we implement runnable we need to take the methods that we need only. but if you extend u will be taking all the methods of the thread class. This increases over head and also the comlpilation time.

  Was this answer useful?  Yes

saurabh80

  • Oct 27th, 2006
 

Because,

By using implement we can inherite multiple interface .So this is goode    for multiple inheritance  and extending more methos to that particular class   

  Was this answer useful?  Yes

Naresh N

  • Dec 12th, 2006
 

HiBy using extend key word we can extend only one class per class, By using impliments key we can impliment many interfaces separated by ",".When u'r going to use thread it's better to impliment runnable interface instead of extending Thread class bcoz if we want to extend one more class it is not possible in this senario.Thanks,Naresh N.

  Was this answer useful?  Yes

puneet mishra

  • Dec 23rd, 2006
 

when we implement interface(runnable).we r not getting extra overhead(like methods) and if extends then we'll get overhead of class b'coz all the classes in java extend Object class(cosmic superclass).Object class has more methods,i have no need of using of these methods like protected clone() and protected finalize().

  Was this answer useful?  Yes

puneet mishra

  • Dec 23rd, 2006
 

when we implement interface (runnable),i not getting extra overhead.but in case of extends class thead.then im getting overhead of the class.in java every class extends Object class(comic superclass) which has more methods like protected clone() and protected finalize()[this method is used by garbage collector]

  Was this answer useful?  Yes

Jay Bardia

  • Jan 8th, 2007
 

Extending or Inheritance signifies a 'is a type' of relationship, if your class is not a 'type' of Thread then its a bad OO design if a class is extending from Thread, in that case implementing the Runnable interface gives the flexibility of multi-threaded functionality

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions