ThreadPoolExecutor and finalization

Roger Riggs Roger.Riggs at
Mon Oct 30 15:27:36 UTC 2017


There is a test 

It only tests it for Executors of newSingleThreadExecutor, not for the 
so I wondered if there was some open issue.


On 10/30/2017 11:02 AM, David Lloyd wrote:
> On Mon, Oct 30, 2017 at 9:43 AM, Roger Riggs <Roger.Riggs at> 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.

More information about the core-libs-dev mailing list