Time to retire System.runFinalizersOnExit?
Peter Levart
peter.levart at gmail.com
Thu Jan 29 09:26:41 UTC 2015
On 01/29/2015 08:34 AM, David Holmes wrote:
>> Wouldn't it be possible to make the method safe?
>>
>> Finalizers are usually run against un-reachable objects. If the Shutdown
>> sequence made sure all threads are stopped except the thread executing
>
> How do you propose to make sure all threads are "stopped"? That would
> potentially introduce more problems and strange new behaviours.
Yes, that would be a problem. Calling Thread.stop() for them would be
dangerous. Even if all threads were captured in a special kind of
safepoint except the shutdown thread, it would not be safe since
finalizers could try to enter synchronized blocks that are held by the
captured threads and a deadlock would occur.
It seems there's no way out.
Regards, Peter
>
> Cheers,
> David
>
>
>> Shutdown sequence, then all objects would become effectively unreachable
>> (except being reachable from shutdown thread that can assume the role of
>> finalizer thread and run the finalizers...).
>>
>> Peter
More information about the core-libs-dev
mailing list