If you want to ensure something is run before VM exit, add a shutdown hook.
If you really want to run all the finalizers, you can always run a variant of GcFinalization in your shutdown hook, although as always running during shutdown increases the risk greatly. On Tue, Jan 27, 2015 at 6:48 AM, Peter Levart <peter.lev...@gmail.com> wrote: > On 01/27/2015 01:54 PM, Peter Levart wrote: > >> A poor-man's escape hatch is a shutdown hook that calls >> System.runFinalization(). Which might interfere with other shutdown hooks >> that run concurrently (runFinalizersOnExit runs finalizers after all >> shutdown hooks are finished). >> > > Not really. This only runs finalizers for Objects pending finalization, > while runFinalizersOnExit runs it for all Objects with finalize() methods > that have not been invoked yet. A big difference. So there's no alternative > if this method is removed. > > Peter > >