[concurrency-interest] increment()/decrement() methodson atomicInteger ?

David Holmes dholmes at dltech.com.au
Tue May 31 23:48:55 EDT 2005


Yechiel Feffer writes:
> Yes, thanks David, this was my point,delegation of the increment op to the
processor
> by the JVM, but I disagree with you that there is no real diff' between
cas and
> atomic incrementation. This is true for a single threaded env' but in a
"packed"
> multi-threaded env' the cas retry loop may iterate several times,
rejecting the op'.
> This can be avoided by a delegated incrementation, and is not needed in
this case
> since I dont want to know the result after.

Yes it is possible that a highly contended atomic variable could require
several CAS retries. Is it likely? I think not, though of course you could
construct a scenario that exercises this aspect.

If anyone were to encounter such an occurrence in practice then it would be
reasonable grounds for submitting an RFE to specialise those actions to
avoid the use of CAS. As I said the current scheme makes life a lot simpler
at both the Java and JVM level.

Cheers,
David Holmes



More information about the Concurrency-interest mailing list