What is more advisable to create a thread, by implementing
a Runnable interface or by extending Thread class?
Answers were Sorted based on User's Feedback
Creating a thread using implementing Runnable interface
are more advisable. Suppose we are creating a thread by
extending a thread class, we cannot extend any other class.
If we create a thread by implementing Runnable interface,
we can extend another class.
Is This Answer Correct ? | 6 Yes | 0 No |
Answer / devarathnam c,kotagudibanda(po
Hi...To create a Thread ,implement the Runnable interface
it is more advisable than extending a Thread class.By
extending the Thread class u can't achieve the multiple
inheritance.So implementing the Runnable interface is good
programming practice.
public class ThreadTest extends Thread,Applet
//This is illegal
public class ThreadTest extends Applet implements Runnable
//This is legal.
Is This Answer Correct ? | 3 Yes | 0 No |
Answer / abcd
Suppose ..you want to work with thread and also with a
class from AWT package.
java rule is that : YOu cannot extend more one class in
your program.
So it is adviseable to implement the runnable interface and
extend any other class which you desire....
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / harish
When u extend a Thread each of your thread has a unique
object associated with it,where as with Runnable interface
may threads share the same object instance.
Is This Answer Correct ? | 1 Yes | 0 No |
What enableEvents() method do?
What is map and hashmap? also tell the difference.
Explain method local inner classes ?
Why Java doesn’t support multiple inheritance?
What is the main advantage of passing argument by reference?
What do you mean by Hash Map and Hash Table?
What is the use of singleton class?
What are disadvantages of java?
What is the use of isempty in java?
we have syntax like for(int var : arrayName) this syntax is to find whether a number is in the array or not.but i want to know how to find that number's location.
what is the difference between System.exit() and System.exit(1)?
1 Answers eClinical Solutions, eClinical Works, eClinicalWorks,
How big is a 64 bit float?