[concurrency-interest] concurrent counter : incrementAndGet

Aleksey Shipilev aleksey.shipilev at gmail.com
Sat Aug 13 19:13:57 EDT 2011

You might want to get the idea from JPA-s sequencers like this: get
each caller thread its own local range of numbers it can count, once
thread depletes the region, atomically allocate another region. You
can then greatly reduce contention by controlling region range. This
is still provide unique values in every thread, with some
non-monotonic perturbations.


On Sun, Aug 14, 2011 at 2:57 AM, Jeff Hain <jeffhain at rocketmail.com> wrote:
> Hello.
>    To continue on the subject of concurrent counters, does anyone
> know one that could be used instead of AtomicLong.incrementAndGet()
> (possibly providing non-monotonic results, or monotonic but with gaps),
> and would scale better?
>    I tried to do something in that direction, but it's sometimes actually
> worse
> (which still surprises me: I'm not totally aware of what I carefully made
> yet ;).
> Regards,
> Jeff
> _______________________________________________
> 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