From: Robert Klemme Date: 2005-04-13T15:09:36+09:00 Subject: Re: ability to run finalizers at a given point of a program? "Glenn Parker" schrieb im Newsbeitrag news:425C50C4.4070504@comcast.net... > Guillaume Cottenceau wrote: >> >> Ok, since I know that no one will want to do that without a more >> precise example, here it is: what happens when the resource is >> allocated and worked on first, then in a totally different part of the >> program, much later, results are extracted from it - and this >> extraction can also possibly be performed multiple times, then again >> later (laaaaaater) the object is collected? Does this block trick >> still work? It seems not, if I understand it correctly. > > Fair enough, long-lived objects are not suitable for the block-wrapping > trick. Not necessarily. It might just be that the block is on a higher level. But yes, there are applications where the pattern is awkward to apply. > But that still doesn't explain the nature of the work you want to do in a > finalizer. > > Do you know when the last "extraction" has been done (making it safe for > your finalizer to run)? Can you use that knowledge to explicitly run the > finalization method, instead of waiting for the GC? That's the exact right question. Because if one can invoke GC manually, then one can as well invoke some cleanup method. Nothing really gained. robert