• 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

Question on garbage collection

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Assume that 'th' is an instance holding a thread object.
th.start() causes the thread to start running and eventually complete its execution.
The object referenced by 'th' is not accessible any more and is garbage collected when the garbage collecter runs.

True / False

The given answer is false.

When 'th' is no long reachable... its elligible for garbage collection.
In the question above, there is a phrase "when the garbage collecor runs"..
So is it not true that when the garbage collector runs, the object referenced by 'th' is garbage collected?

Thanks in advance,
rajani.
 
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The object referenced by th will be eligible for garbage collection once th goes out of scope (assuming there are no other references to that object). In the preceding statement, it is unclear when th goes out of scope.

In my opinion, it is a poorly worded question.
 
reply
    Bookmark Topic Watch Topic
  • New Topic