Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does ThreadLocal clear values created for already finished threads?

Does ThreadLocal automatically clear values created for already finished threads?

like image 846
Pavel Voronin Avatar asked Jan 26 '26 12:01

Pavel Voronin


1 Answers

Yes, the variables are made available for Garbage collections but only if there are no other references to those values (held by some other thread). But when you say a thread is finished, it shouldn't be like a pooled threads. Pooled threads should clear their own variables before they are put back to pool.

like image 76
Vamsi Mohan Jayanti Avatar answered Jan 28 '26 01:01

Vamsi Mohan Jayanti



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!