• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reg java.lang.Thread creation?

 
V. Potluri
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 557
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 )
 
ramesh kumar
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic