Hi, There are 2 ways to use thread in java - Subclass Thread or implement Runnable. Sub classing cannot be done when my class wants to extend some other class and also Runnable approach allow creation of Singleton pattern.
My question is what is the use of allowing subclassing of Thread, when what is required in both the approaches is write code in run(). Why would anyone subclass a Thread ?? Any points in favour of subclassing a Thread is what I need. Thanks in advance.
When you sub class a Thread class, for example, it's like saying your class "is a" Thread. This means that you can call the start() method on an instance of the class and do not really need to create an instance of the Thread class because really an instance of your class "is a" thread. I like extending Thread more than implementing runnable. Does this help? [ May 29, 2002: Message edited by: Aaron O'Brien ]