Help coderanch get a
new server
by contributing to the fundraiser
  • 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?
 
No matter how many women are assigned to the project, a pregnancy takes nine months. Much longer than this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic