Tagged articles
LongAdder
17 articles · Page 1 of 1
This article demystifies Java's Compare‑And‑Swap (CAS) instruction, shows how atomic classes like AtomicInteger achieve lock‑free increments, discusses CAS's three main drawbacks, surveys the entire java.util.concurrent.atomic family, and explains how LongAdder improves high‑contention counting.
Atomic ClassesCASConcurrency
0 likes · 15 min read

When a service’s QPS jumps from two to eight million, a single global lock can turn a multi‑core machine into a bottleneck, so the article walks through coarse‑lock problems, fine‑grained locking, read‑write separation, optimistic reads, CAS‑based lock‑free techniques, LongAdder and advanced data structures, showing when each step is appropriate for high‑throughput systems.
CASJavaLocks
0 likes · 19 min read

This article details a production-ready QPS monitoring implementation for Spring Boot using sliding window algorithm with RingBuffer and LongAdder for high-concurrency safety, integrated with Micrometer for metrics exposure, covering algorithm design, code implementation, performance optimization, and distributed monitoring strategies.
Distributed MonitoringLongAdderMicrometer
0 likes · 19 min read

This article explains the principles, advantages, and drawbacks of CAS, LongAdder, and AtomicLong in Java, illustrating why Alibaba recommends LongAdder for high‑concurrency counter scenarios, how the ABA problem arises, and how AtomicStampedReference can mitigate it.
CASConcurrencyDistributedSystems
0 likes · 9 min read

This article explains the principles, advantages, and drawbacks of Java's AtomicLong and LongAdder counters, describes the CAS operation and its ABA problem, and analyzes why Alibaba recommends LongAdder for high‑concurrency, high‑availability scenarios in distributed systems.
CASConcurrencyJava
0 likes · 7 min read

In high‑concurrency Java applications, LongAdder—introduced in JDK 8 and using partitioned cells to reduce contention—generally outperforms the single‑value AtomicLong, which relies on CAS and can cause CPU waste under heavy load, so Alibaba advises LongAdder for scalable distributed counters, though memory usage and workload specifics must be considered.
BackendCASConcurrency
0 likes · 7 min read

This article explains the principles of CAS, compares Java's AtomicLong and LongAdder counters, highlights the ABA problem, and shows why Alibaba recommends LongAdder for high‑concurrency scenarios due to its segmented lock design, better performance, scalability, and ease of use.
CASConcurrencyLongAdder
0 likes · 8 min read

Implementing real‑time statistics in a Java performance testing engine involves adding TPS and average latency counters, creating a controllable monitoring thread, using LongAdder for high‑concurrency metrics, and gracefully shutting down the thread, enabling testers to instantly observe system load and detect bottlenecks.
JavaLongAdderMultithreading
0 likes · 6 min read

This article introduces Java's java.util.concurrent.atomic package, detailing the core atomic classes—AtomicBoolean, AtomicInteger, AtomicLong, and LongAdder—including their constructors, key methods, typical use cases, and performance considerations in high‑concurrency scenarios for developers seeking efficient thread‑safe operations.
JavaLongAdderMultithreading
0 likes · 9 min read

This article explains how Java's LongAdder works, compares its API and performance to AtomicLong, provides usage examples and a benchmark showing its superior throughput under high thread contention, while noting its higher memory cost and appropriate scenarios for adoption.
ConcurrencyJavaLongAdder
0 likes · 7 min read

This article explains why LongAdder was introduced to overcome AtomicLong's CAS contention bottleneck, explores the design of Striped64 and its cells, and walks through key source code snippets of LongAdder, DoubleAdder, and the longAccumulate method, highlighting concurrency mechanisms and performance considerations.
CASConcurrencyJava
0 likes · 13 min read

This article explains how to write a concurrent unit test for the AssetService.update method using thread pools, CountDownLatch, AtomicInteger, and then suggests optimizations such as replacing AtomicInteger with LongAdder and employing CyclicBarrier to increase contention, providing full code examples and detailed explanations.
ConcurrencyCyclicBarrierJava
0 likes · 9 min read

This article examines common misconceptions about Java concurrency utilities such as ThreadLocal, ConcurrentHashMap, and CopyOnWriteArrayList, demonstrates real‑world bugs caused by thread reuse and non‑atomic operations, and provides concrete solutions and performance‑tested alternatives.
ConcurrentHashMapCopyOnWriteArrayListJava Concurrency
0 likes · 12 min read

This article examines the thread‑safety of the volatile keyword under multi‑write scenarios, demonstrates its failure with a concurrent counter test, and benchmarks LongAdder against AtomicInteger using JMH, revealing LongAdder’s superior performance under high contention and AtomicInteger’s advantage in low‑contention environments.
ConcurrencyJMHJava
0 likes · 8 min read

An in‑depth Java performance study explores LongAdder, compares it with AtomicLong and lock‑based counters using JMH, and walks through successive custom implementations (V0‑V5) that apply striping, modulo optimization, false‑sharing elimination, and advanced hash probing to approach or surpass LongAdder’s throughput.
JMHJava ConcurrencyLongAdder
0 likes · 16 min read

This article explains the evolution and implementation of Java's JVM‑level locks—including synchronized, ReentrantLock, ReentrantReadWriteLock, and LongAdder—detailing their lock‑upgrade process, internal object layout, AQS‑based algorithms, and how they improve concurrency and performance in multithreaded applications.
LocksLongAdderReadWriteLock
0 likes · 24 min read

This article explains how java.util.concurrent.atomic.LongAdder provides a more efficient counting mechanism than AtomicLong under high contention, discusses its trade‑offs in space and precision, presents JMH benchmark results, and walks through the internal implementation details such as cells, CAS loops, and hash‑based distribution.
CASConcurrencyJMH
0 likes · 13 min read
