How can one decide whether to use Thread class or Runnable interface. I know one scenario where if my class already extends another class, it has no choice but to implement the Runnable interface. Are there any other scenarios ? Regards, Mustang.
netharam ram
Ranch Hand
Joined: Aug 09, 2001
Posts: 202
posted
0
Suppose u want u'r class to act as a Thread i.e to be instantiated from other classes u extend u'r class from java.lang.Thread. eg).performing a certain calculation. If u r using threads within u'r class to do a certain job u implement runnable. eg). using swing & displaying some animations. This is what I know. Happy middling with java. Netharam.
Dave Vick
Ranch Hand
Joined: May 10, 2001
Posts: 3244
posted
0
Basically, if your class is a subclass of another class you can't extend thread so you'd have to use Runnable.
Its your choice. Typically one extends a class to add to its functionality though. Since their is no double inheritance, you can simply use Runnable, but it does not matter one bit.