RFR: 8003246: Add Supplier to ThreadLocal
forax at univ-mlv.fr
Wed Dec 5 19:56:04 UTC 2012
On 12/05/2012 08:51 PM, Doug Lea wrote:
> On 12/05/12 14:39, Akhil Arora wrote:
>> This patch adds a constructor to ThreadLocal to supply initial values
>> using the
>> new Supplier functional interface. Please review. This work was done
>> by Jim Gish.
> I see that EVERY ThreadLocal now has an extra field in case it is
> used with a Supplier. I expect that those web frameworks that create
> thousands of ThreadLocals (not just instances of Threadlocals)
> will see a measurable space increase. has anyone measure the impact?
> Did anyone consider instead defining a SuppliedThreadLocal
> subclass (or some better name) to isolate the impact?
The class doesn't even to have a name, one can add a static factory
method in ThreadLocal and use an anonymous class to implement it.
The other problem is that Supplier<T> should be replaced by Supplier<?
extends T> everywhere in the code.
More information about the core-libs-dev