Win a copy of Microservices Testing (Live Project) this week in the Spring 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:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic