Win a copy of Rust Web Development this week in the Other Languages forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Thread questions

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Can you please answer the questions?
1.What is the type of the �target� data member of the Thread class?
2.How is �target� used to support running direct subclass of the Thread class versus running class implementing Runnable interface?

Thanks
Santhosh
 
author
Posts: 23912
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sanny kumar:
Hi,

Can you please answer the questions?
1.What is the type of the �target� data member of the Thread class?
2.How is �target� used to support running direct subclass of the Thread class versus running class implementing Runnable interface?

Thanks
Santhosh



The "target" instance variable of the Thread class is an internal private variable. It is not officially documented, and hence, subject to change in future implementations.

In the current implementation, it is used to store the Runnable object that is passed to the Thread object (assuming the constructor that takes the Runnable is used). The default run() method, if the method has not been overridden, will check the target variable for a Runnable object. And if one exist, it will call the run() method of the runnable object.

Henry
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic