[concurrency-interest] Bug in ThreadLocal ?
hanson.char at gmail.com
Fri Apr 13 14:02:23 EDT 2007
According to the javadoc of ThreadLocal#remove (in jdk1.6),
"If this thread-local variable is subsequently read by the current
thread, its value will be reinitialized by invoking its initialValue method"
So I would expect, within the same thread, a ThreadLocal#get followed
followed by ThreadLocal#get would result in ThreadLocal#initialValue being
But this is not the case. The last "get" did not cause the "initValue" to
be invoked. When I looked at the code of the "remove" and "get" method
implementation, it seems there is a bug in that the internal "t.threadLocals"
should be set to null when the remove method is invoked, but is not
currently the case.
Am I mistaken or is this a bug ? Comment ?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Concurrency-interest