• Post Reply Bookmark Topic Watch Topic
  • New Topic

unreferenced objects are garbage collected  RSS feed

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
In the code below

new Thread(this).start();
Assuming that "this" implements Runnable, does the thread get a
chance to complete before being Garbage collected?
Thanks in Advance,
 
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, the JVM will wait until the thread complete processing on "this" object...
Objects are eligible to be garbage-collected, only after the things are done on them....
I'm sorry, if my explanation is not that clear... :roll:
 
Anand Sidharth
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,
Perfectly fine
 
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While the thread is running, it is referenced by the runtime system, so it can't be garbage collected.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!