[concurrency-interest] Re : concurrent counter : incrementAndGet

Jeff Hain jeffhain at rocketmail.com
Sun Aug 14 07:03:06 EDT 2011

   That could work well for some cases indeed, but I'm working on a sort
of Disruptor, using the counter with modulo to pick up slots to write to in
a cyclic array, monotonically, or non-monotonically but for a short time
(for readers not to be blocked on a not-yet-written slot), and any writer
can stop to work anytime; in this case I don't see how that could apply


De : Aleksey Shipilev <aleksey.shipilev at gmail.com>
À : Jeff Hain <jeffhain at rocketmail.com>
Cc : concurrency-interest at cs.oswego.edu
Envoyé le : Dim 14 août 2011, 1h 13min 57s
Objet : Re: [concurrency-interest] concurrent counter : incrementAndGet

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20110814/d71a00f6/attachment.html>

More information about the Concurrency-interest mailing list