Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread ( dead thread)

 
Muhammad Usman
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello to all ;
Q. Once a thread is dead, we can,t start it, but access its data ( i.e methods and member variables). What does it mean ?
 
Dave Vick
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
muhammad
Check out the code below:

Once the mt thread is dead it can not be restarted, calling start on it again does nothing. But you can still access it variables and methods like any other object. In fact, you can even call the run method directly and have it execute again. It just wouldn't run in its own thread it would inline like any other method. Hope that helps
[ March 25, 2002: Message edited by: Dave Vick ]
 
Jeffy Yang
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thread object or objects implemented Runnable interface are the same as other objects. So, even if a thread is dead, if a you still have a reference to that object, the object will not be GC, you can visit it's methods or members as other objects.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic