ThreadPoolExecutor and finalization

David Lloyd david.lloyd at redhat.com
Mon Oct 30 15:02:59 UTC 2017


On Mon, Oct 30, 2017 at 9:43 AM, Roger Riggs <Roger.Riggs at oracle.com> wrote:
> ThreadPoolExecutor has a responsibility to cleanup any native resources it
> has allocated (threads) and it should be free to use whatever mechanism is appropriate.

I wonder though whether TPE.finalize() is ever actually hit in
practice: TPE is (by definition) a thread pool, and every live thread
in that pool has (by way of TPE.Worker) a strong reference to the TPE
itself via an outer class reference which is passed around in enough
places to make me think that it would never actually be collectable in
a real-world situation, unless all core threads were allowed to time
out.

-- 
- DML


More information about the core-libs-dev mailing list