How java uses LongAdder counters
Editor to share with you how java uses LongAdder counters, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Use LongAdder counters
In highly competitive situations, java.util.concurrent.atomic.LongAdder is used for counting instead of AtomicLong/AtomicInteger.
LongAdder can keep the values the same across multiple cells, but you can increase their values if necessary, but this results in higher throughput and increased memory consumption than the parent class AtomicXX.
LongAdder counter = new LongAdder (); counter.increment ();... long currentValue = counter.sum (); that's all about the article "how java uses LongAdder counters". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!