Sponsored Link •
|
Advertisement
|
Advertisement
|
This page contains an archived post to the Design Forum (formerly called the Flexible Java Forum) made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.
Message:
The arcticle states that there is no guaranteed order with respect to garbage collection. I was wondering, then, if it safe to utilize a reference to an object that is only referred to by the object being garbage collected within a finalize method. Consider that object A references object B and object B references object C. B's reference to C is the only reference to C, and A's reference to B is the only reference to B. B becomes eligible for garbage collection because A drops its reference to it. Can B, in its finalize clause, pass its reference to C to another object? I am concerned that the GC might recognize that the only reference to C is an object that is in the process of being The reason that I want to do this, is that C represents a resource (database connection) that I have in a pool. If the object using the resource gets garbage collected, I want to return C to the pool. Jeff
Replies: |
Sponsored Links
|