Xueming Shen wrote:
> I'm not a GC guy, so I might be missing something here, but if close()
> is being explicitly invoked by some thread, means someone has a strong
> reference to it, I don't think the finalize() can kick in until that
> close() returns

This is not correct. You can re-publish the reference from another finalizer 
method and thereby allow another thread to access the object concurrently with 
the finalizer.

Here's a possible sequence of events:
1) GC runs and determines that A and B are finalizable
2) Finalizer thread run A.finalize()
3) A.finalize publishes reference to B in static variable
4a) Another thread reads the static variable and calls B.close()
4b) Finalizer thread runs B.finalize()

Regards,
Jeroen

Reply via email to