Mark Space <markspace@sbc.global.net> writes:
I guess one could venture "Objects that are still in use, such as by a
reference." Then add "Is that along the lines you are looking for?
Yesterday I had to think about something inspiring this
exercise:
public class A
{ private O o = new O();
public void run(){ o.something( this ); }
public void unlink(){ o = null; /* can o be reclaimed here? */ }}
Given the code of the above class A (that can't be changed),
one might be inclined to assume that directly after
?o = null;?, the object ?o? can always be safely reclaimed.
This is not about reflection tricks to get a copy of the
private field ?o? (these are not allowed here). Since
there is no ?getter? for ?o?, the reference ?o? is kept quite
confidentially within the class ?A?.
Still, there is at least one situation, where ?o? should not
be reclaimed directly after ?o = null;?. What would be such a
situation?
reference to the o object that is still accessible. Moreover, run()
could be running.
thread.