• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Reg java.lang.Thread creation?

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 558
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 )
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic