In fact, the key point for garbage collection question is to
remember the following rule :
"An object is eligible for garbage collection when no live
thread can access it"
(taken from Sierra&Bates preparation book, thanks to them).
Also remember that you can only say when an object is eligible for garbage
collection, not when the garbage collector run.
With this rule in hand, you can solve the above problem, which is an
example of "island of isolation".