Hi Friends, can you give difference between extending thread
class and implementing runnable interface.
Answers were Sorted based on User's Feedback
Answer / ravikiran
By extending a thread class we will be restricted to the
implementation for single class only,by implementing
Runnable interface we will get extended for implementing
more than one thread
Is This Answer Correct ? | 3 Yes | 1 No |
Answer / murali.25
both will achieve the same functionality. Usually we implement runnable interface because if we extend thread and if we want to any application specific class, its not possible because java doesnt support multiple inheritance.
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / nagendra kumar
1.extends Thread and implements Runnable both are
fuctionally same.
2.If we use "extends Thread" then there is no scope to
extend another class because java doesn't multiple
inheritance.
3.If we use "implements Runnable" then there is a scope to
extend another class.This definately advantage why because
a programmer wants to extends a class and also use Thread
class features they must use Runnable interface.
Is This Answer Correct ? | 2 Yes | 1 No |
Answer / abnish kumar rajput
If we are going for using extend with thread then there is
no need to create thread object because we have
automatically all the properties of thread class ,then reuse
all these properties.whereas If are going for implement with
thread then we have to create of thread class and then we
have to override all the methods of thread class.because of
abstract class .
Is This Answer Correct ? | 0 Yes | 2 No |
What is an event?
Can we declare a constructor as final?
what is the difference between HashMap and Hashtable
17 Answers Value Labs, Virtusa,
What are the types of casting?
Why we use multi threading instead of multiprocessing?
What is javac used for?
Nullpointer exception is a very common exception. Why is it not made as a checked exception?
what is the difference between Object Based Language and Object Oriented Language?
What is integers and example?
What is Generic in java? Where can we write Generic ( class or method or objects or etc...)? with simple example? Thanks, Bose.
2 Answers Infosys, Tech Mahindra,
How do you use substring in java?
What is local variable and instance variable?