Quantcast
Channel: Use of infinite loop in AtomicInteger.addAndGet(int) - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Answer by hahn for Use of infinite loop in AtomicInteger.addAndGet(int)

$
0
0

compareAndSet or just CAS relates to nonblocking thread-safe algorithms. The increment operation in case of addAndGet is fetching the old value, transform it to the new value and using CAS tries to set the new value, if current wasn't modified during increment. If CAS fails, it would be retried until success. This strategy is efficient in cases when there's no extreme contention.


Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>