why Runnable interface is preferable than extending the
Thread class?
Answer Posted / amit singh
is this prefable why simple
you class A extends other class B
and it also want to be a thread then what you should
beacuse its allow in java that one class extends two class
its not possible in java
class A
{
}
class B extends A
{
}
then what to do to make the thread of class B
so you are going to extends the Thread class too
its biggest blunder in java so you should to prefer
implements the Runnable interface
that it not just the f--k above mention though my ther frnds
thanks imagie
class B extends A implements Runnable
{
public void run()
{
}
}
class C
{
public static void main(String []args)
{
C c = new C();
B b = new B();
Thread t1 = new Thread(b);
t1.start();
}
}
}
and another reason to implements the Runnable interface
when you want to allocate some specific work means to say
that you just whe the thead will create and run ,through the
run method which you define in this class do some
when the thread runs means to say that when you extends
Thread and you not define the run method the default will
run
and when you implements the Runnable you must and needs to
define it do some functionaklity on each thread creation
thanks amitsing2008@gmail.com
amit09mca
Is This Answer Correct ? | 11 Yes | 3 No |
Post New Answer View All Answers
What is the advantage of preparedstatement over statement?
What are 4 pillers of object orinted programming?
Difference between arraylist and hashset in java?
What is a heavyweight component?
Does java support multiple inheritances?
What are disadvantages of java?
What does n mean in java?
Assume a thread has lock on it, calling sleep() method on that thread will release the lock?
What is computer compiler?
What the difference is between execute, execute Query, execute Update?
What are the drawbacks of singleton class?
Is set sorted in java?
What do you understand by the term wrapper classes?
What are the two types of java programming?
What is == and === in javascript?