[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] force finalizers only if finalizers exist

From: John Cowan
Subject: Re: [PATCH] force finalizers only if finalizers exist
Date: Wed, 6 May 2020 13:13:24 -0400

The Right Thing is probably to eventually run the GC on a private thread, at least when multiple threads are running at all.  That way the finalizers run on the same thread that doesn't hold any locks or otherwise risk trouble.  That's what the JVM and the CLR do.

On Wed, May 6, 2020 at 5:42 AM <address@hidden> wrote:
> There might be a situation where a thread is already executing
> ##sys#run-pending-finalizers, but has run out of its time slice, or gc
> interrupted or something. In this situation running
> ##sys#run-pending-finalizers only once might not be enough.

This is basically true, but with threads we make no effort to terminate
them properly once the main thread exists - all unjoined threads will die anyway,
regardless of what they are currently doing.

Also, the interplay between threads and finalizers is more or less
undefined - interrupts are executed in whatever thread happens to be
active and manually forcing finalizers in a different thread than the
main thread is already asking for trouble. This is a known problem of
the threading/interrupt system and needs to be solved differently.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]