have a look at Cliff Click's ConcurrentAutoTable (github fork link for easy viewing):<div><br></div><div><a href="https://github.com/boundary/high-scale-lib/blob/master/src/main/java/org/cliffc/high_scale_lib/ConcurrentAutoTable.java">https://github.com/boundary/high-scale-lib/blob/master/src/main/java/org/cliffc/high_scale_lib/ConcurrentAutoTable.java</a><br>
<br></div><div>original source in sourceforge:</div><div><br></div><div><a href="http://sourceforge.net/projects/high-scale-lib/">Highly Scalable Java | Download Highly Scalable Java software for ...</a></div><div><br><div class="gmail_quote">
On Sun, Aug 14, 2011 at 9:03 PM, Jeff Hain <span dir="ltr"><<a href="mailto:jeffhain@rocketmail.com">jeffhain@rocketmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div style="font-family:arial,helvetica,sans-serif;font-size:10pt"><div><br> That could work well for some cases indeed, but I'm working on a sort<br>of Disruptor, using the counter with modulo to pick up slots to write to in<br>
a cyclic array, monotonically, or non-monotonically but for a short time<br>(for readers not to be blocked on a not-yet-written slot), and any writer<br>can stop to work anytime; in this case I don't see how that could apply<br>
easily.<br><br>-Jeff<br></div><div style="font-family:arial,helvetica,sans-serif;font-size:10pt"><br><div style="font-family:arial,helvetica,sans-serif;font-size:10pt"><font face="Tahoma" size="2"><hr size="1"><b><span style="font-weight:bold">De :</span></b> Aleksey Shipilev <<a href="mailto:aleksey.shipilev@gmail.com" target="_blank">aleksey.shipilev@gmail.com</a>><br>
<b><span style="font-weight:bold">À :</span></b> Jeff Hain
<<a href="mailto:jeffhain@rocketmail.com" target="_blank">jeffhain@rocketmail.com</a>><br><b><span style="font-weight:bold">Cc :</span></b> <a href="mailto:concurrency-interest@cs.oswego.edu" target="_blank">concurrency-interest@cs.oswego.edu</a><br>
<b><span style="font-weight:bold">Envoyé le :</span></b> Dim 14 août 2011, 1h 13min 57s<br><b><span style="font-weight:bold">Objet :</span></b> Re: [concurrency-interest] concurrent counter : incrementAndGet<br></font><div class="im">
<br>You might want to get the idea from JPA-s sequencers like this: get<br>each caller thread its own local range of numbers it can count, once<br>thread depletes the region, atomically allocate another region. You<br>can then greatly reduce contention by controlling region range. This<br>
is still provide unique values in every thread, with some<br>non-monotonic perturbations.<br><br>-Aleksey.<br><br>On Sun, Aug 14, 2011 at 2:57 AM, Jeff Hain <<a href="mailto:jeffhain@rocketmail.com" target="_blank">jeffhain@rocketmail.com</a>> wrote:<br>
> Hello.<br>><br>>
To continue on the subject of concurrent counters, does anyone<br>> know one that could be used instead of AtomicLong.incrementAndGet()<br>> (possibly providing non-monotonic results, or monotonic but with gaps),<br>
> and would scale better?<br>><br>> I tried to do something in that direction, but it's sometimes actually<br>> worse<br>> (which still surprises me: I'm not totally aware of what I carefully made<br>
> yet ;).<br>><br>> Regards,<br>><br>> Jeff<br>><br>><br>> _______________________________________________<br>> Concurrency-interest mailing list<br>> <a href="mailto:Concurrency-interest@cs.oswego.edu" target="_blank">Concurrency-interest@cs.oswego.edu</a><br>
> <a href="http://cs.oswego.edu/mailman/listinfo/concurrency-interest" target="_blank">http://cs.oswego.edu/mailman/listinfo/concurrency-interest</a><br>><br>><br></div></div></div>
</div></div><br>_______________________________________________<br>
Concurrency-interest mailing list<br>
<a href="mailto:Concurrency-interest@cs.oswego.edu">Concurrency-interest@cs.oswego.edu</a><br>
<a href="http://cs.oswego.edu/mailman/listinfo/concurrency-interest" target="_blank">http://cs.oswego.edu/mailman/listinfo/concurrency-interest</a><br>
<br></blockquote></div><br></div>