[concurrency-interest] Soliciting input about removeAllThreadLocals

Joshua Bloch joshua.bloch@sun.com
Sun, 08 Dec 2002 22:49:41 -0800


David,

>Sorry but thats a vacuous example. What does the thread local do if it
>is totally independent of any task the thread may execute.
>
  I already gave the logging example. Or how about a call counting 
facility?  I agree that these aren't great, detailed examples, but I 
*strongly* believe that the burden of proof is on those who want to add 
the new facility.

>>>I can easily imagine usage of thread-locals in a way that
>>>are really
>>>task-local and thus it would be wrong not to reset them when a new
>>>task commences.
>>>
>>>      
>>>
>>In this sort of use, the ThreadLocal is generally updated
>>manually in a finally block so there's no need ot reset.
>>    
>>
>
>You're assuming that the task knows ahead of time that it is using
>thread locals. 
>
   Not necessarily.  The use of thread locals could be hidden behind a 
library that (say) begins and ends transactions.  The transaction data 
block would be automagically carried along by the thread.  (For what 
it's worth, I did this at CMU and Transarc, and it works fine.)

   Sorry everybody.  I realize that David and I are beating this one to 
death.  I promise to shut up.

                 Josh