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

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: 23958
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
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic