Scoped variables

John Rose john.r.rose at oracle.com
Wed Dec 5 00:07:28 UTC 2018


On Dec 4, 2018, at 9:12 AM, Andrew Haley <aph at redhat.com> wrote:
> 
> Josh Bloch said in that discussion that he didn't intend people to use
> ThreadLocal.get() with high frequency, but it's clear that Java
> programmers find them so attractive they'll use them all over the
> place.
> 
> For example, in Chapter 7 of The Art Of Multiprocessor Programming a
> ThreadLocal is used to create a queue node for a CLH lock.  It's not
> sensible to use a ThreadLocal for this, but it makes the example code
> shorter. Of course, every call to acquire() then takes 12 field loads
> just to get to the local queue node.

That's all to the good if we can make FL's (F=fiber or frame) faster
than TLs.  It will prompt people to migrate away from a poor abstraction
(for the use cases we are discussing) to a good one, with performance
as the reward.  As it should be.





More information about the loom-dev mailing list