> > Java does not guarantee that finalizers run, and it certainly > > does not guarantee that they will run before Java decides to > > garbage collect that object.
> Are you sure? Yes, but you misunderstood, and my phrasing wasn't clear. "The Java programming language does not specify how soon a finalizer will be invoked, except to say that it will happen before the storage for the object is reused." In other words, you cannot count on Java to call the finalize method if it has not yet decided to garbage collect the object. One of the aspects of garbage collection is determining that an object is no longer reachable, and the earliest that a finalizer would be called is when that determination has been made. The use of a PhantomReference is considered a more reliable approach. That mechanism is keyed by the determination that an object is no longer reachable except via a PhantomReference. See http://java.sun.com/j2se/1.4.2/docs/api/java/lang/ref/PhantomReference.html for more details. --- Noel --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
