• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Thread Object

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are Thread objects are like any other Objects of java.
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes. Like all other classes, the Thread class too extends from the Object class. So it can be considered and treated as a 'normal object' in java.
 
Aruna Balasuriya
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hiruka Sandev wrote:Yes. Like all other classes, the Thread class too extends from the Object class. So it can be considered and treated as a 'normal object' in java.



Then upon calling a start method of a thread object how a new method stack generated.
 
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Aruna Balasuriya wrote:Then upon calling a start method of a thread object how a new method stack generated.



Why don't you take a look at Thread's sources..? It's in src.zip in our JDK installation folder! You will see that the method that starts the new thread of execution is a native method:

 
Hiruka Sandev
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To simply put it, that is how the start method in the Thread class has been implemented.

You may implement your class to do anything that you like, but that doesn't mean that an instance of your class cannot be considered to be a regular object in java.

For example say that you have written a class which has a method that writes a record to a DB when that method is invoked. Would you not consider an instance of your class to be like any other object in Java?
 
reply
    Bookmark Topic Watch Topic
  • New Topic