This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
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 ]