On 18/11/2014 05:11, Bernd Eckenfels wrote:
Unfortunatelly the ThreadLocal#get() will call #setInitialValue() in all cases, and this will in turn call createMap(). setInitialValue() could avoid to call createMap() when value is null. This would reduce the number of created thread specific maps and entries (and also weak references to the thread).
There's no guarantee that the execution of initialValue was trivial even if it returns null.
I don't know whether or not mixing up the execution paths through get would harm performance.
Tom
