[concurrency-interest] Numa and ReentrantLock

Doug Lea dl at cs.oswego.edu
Fri Aug 27 08:37:40 EDT 2010

> Hi Doug,
> I have a requirement where-in I spin by calling "trylock()" a configured
> number of times before i go in for a blocking version.
> Something like adaptive spinning on intrinsic locks.

Yes, this is an intended common use for tryLock -- we in the
library don't know if/how you'd like to do adaptive spins,
but we try to make it easy to do so.

> My only concern is this spinning is on a single variable which would be on
> remote memory for all but one thread on NUMA machines.

This is unlikely to be a major concern, but you might heuristically
improve good-citizenship by occasionally invoking Thread.yield()
if you spin a lot. For example, yield every 64 spins. This has no
guaranteed effects, but in practice helps.


> Regards
> Mohit
> _______________________________________________
> Concurrency-interest mailing list
> Concurrency-interest at cs.oswego.edu
> http://cs.oswego.edu/mailman/listinfo/concurrency-interest

More information about the Concurrency-interest mailing list