Tagged articles
14 articles
Page 1 of 1
Java Captain
Java Captain
May 4, 2025 · Backend Development

Understanding Java Counter Implementations: AtomicLong vs LongAdder

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.

CASJavaatomiclong
0 likes · 7 min read
Understanding Java Counter Implementations: AtomicLong vs LongAdder
Java Tech Enthusiast
Java Tech Enthusiast
Apr 12, 2025 · Backend Development

Understanding AtomicLong vs LongAdder in Java Concurrency

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.

BackendCASJava
0 likes · 7 min read
Understanding AtomicLong vs LongAdder in Java Concurrency
FunTester
FunTester
Mar 8, 2025 · Backend Development

How to Add Real‑Time TPS and Latency Display to a Java Performance Test Engine

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.

JavaPerformance Testinglongadder
0 likes · 6 min read
How to Add Real‑Time TPS and Latency Display to a Java Performance Test Engine
FunTester
FunTester
Jan 3, 2025 · Backend Development

Java Atomic Package Classes: AtomicBoolean, AtomicInteger, AtomicLong, and LongAdder

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
Java Atomic Package Classes: AtomicBoolean, AtomicInteger, AtomicLong, and LongAdder
FunTester
FunTester
Mar 28, 2022 · Backend Development

Why LongAdder Beats AtomicLong in High‑Concurrency Java Performance Tests

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.

JavaPerformance Testingatomiclong
0 likes · 7 min read
Why LongAdder Beats AtomicLong in High‑Concurrency Java Performance Tests
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Jul 10, 2021 · Backend Development

Concurrent Unit Testing of AssetService.update with Optimization Techniques

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.

AtomicIntegerCyclicBarrierJava
0 likes · 9 min read
Concurrent Unit Testing of AssetService.update with Optimization Techniques
Code Ape Tech Column
Code Ape Tech Column
Dec 27, 2020 · Backend Development

Why ThreadLocal and ConcurrentHashMap Can Still Cause Bugs—and How to Fix Them

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
Why ThreadLocal and ConcurrentHashMap Can Still Cause Bugs—and How to Fix Them
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Aug 26, 2020 · Backend Development

Testing Volatile Thread Safety and Comparing LongAdder vs AtomicInteger Performance in Java

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.

AtomicIntegerJMHJava
0 likes · 8 min read
Testing Volatile Thread Safety and Comparing LongAdder vs AtomicInteger Performance in Java
Xiao Lou's Tech Notes
Xiao Lou's Tech Notes
May 19, 2020 · Backend Development

Can You Build a Faster Counter Than Java’s LongAdder? A Deep Dive

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 concurrencyfalse sharing
0 likes · 16 min read
Can You Build a Faster Counter Than Java’s LongAdder? A Deep Dive
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Feb 17, 2020 · Backend Development

Understanding JVM-Level Locks in Java: synchronized, ReentrantLock, ReentrantReadWriteLock, and LongAdder

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.

LocksReadWriteLockReentrantLock
0 likes · 24 min read
Understanding JVM-Level Locks in Java: synchronized, ReentrantLock, ReentrantReadWriteLock, and LongAdder
Ziru Technology
Ziru Technology
Sep 19, 2019 · Backend Development

Why LongAdder Beats AtomicLong in High Contention: Deep Dive into Java’s Concurrent Counter

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.

CASJMHJava
0 likes · 13 min read
Why LongAdder Beats AtomicLong in High Contention: Deep Dive into Java’s Concurrent Counter