On Thu, 23 Jan 2025 14:32:22 GMT, Maurizio Cimadamore <mcimadam...@openjdk.org> wrote:
>> Exactly. initialValue happens on-demand, not upfront, i.e. in the very >> moment the VT calls get(). >> Whereas terminate happens as the last action of the CT. > > If this is really the case, I agree that there doesn't seem to be an > alternative to use `ofAuto`. In which case you don't really need a > TerminatingThreadLocal -- a CarrierThreadLocal is just fine (given we don't > really have anything to do on close). alternatively - we could have some kind of internal "forceClose" API which doesn't check the owner thread. Some care is probably needed as the access is now on a different thread, so we'll need to make sure that some volatile accesses are used by this method, otherwise it might "miss" cleanup actions. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/23142#discussion_r1927082367