aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Reg java.lang.Thread creation? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Reg java.lang.Thread creation?" Watch "Reg java.lang.Thread creation?" New topic
Author

Reg java.lang.Thread creation?

V. Potluri
Ranch Hand

Joined: Mar 29, 2007
Posts: 36
Hi All,

In Page# 677 of SCJP5 by Kathy:

It is discouraged to create a Thread using java.lang.Thread class because it is not good OO practise!!!

It makes sense [from OO perspective] to extend java.lang.Thread is when you have a more specialized version of a Thread class.

***I didn't understand above statements. Kindly any one can give more detail info. related to above statements.****

Thanks in advance.

Thanks,
Potluri
Srinivasan thoyyeti
Ranch Hand

Joined: Feb 15, 2007
Posts: 557
Hi,

1)People avoid creating Thread "by extending Thread" because
They might need to extend another class.
[they can't extend Thread here]

2)One will extend from thread, to override the current thread functions behavior ( They have their own design issues )


Thanks & Regards,<br />T.Srinivasan,<br />SCWCD 1.4(89%),SCJP 5.0(75%)<br />"That service is the noblest which is rendered for its own sake." - Mahatma Gandhi
ramesh kumar
Greenhorn

Joined: Aug 15, 2006
Posts: 25
class Animal
{


}
class Cat extends Animal
{

}

Cat is one kind of Animal,here Cat inherits all the properties of animal and it can have it's own properties.So if you are extending one class from super class you are deriving one class specific to that super class.

So if you are extending Thread you should be able to create specific kind Thread.That is why it is not good OO design.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Reg java.lang.Thread creation?
 
Similar Threads
Overriding start() method of Threads
java jar Question
Thread
regarding Thread.stop()
Java Supports Multiple Inheritance without interfaces