Tagged articles
18 articles
Page 1 of 1
JakartaEE China Community
JakartaEE China Community
Oct 20, 2025 · Fundamentals

How to Prevent ConcurrentModificationException in Java Collections

The article explains why ConcurrentModificationException occurs when a Java collection is structurally modified during iteration, illustrates typical scenarios such as enhanced‑for loops and multithreaded access, and provides practical solutions including iterator.remove(), thread‑safe collections, synchronized blocks and iterating over copies.

CollectionsConcurrentHashMapConcurrentModificationException
0 likes · 7 min read
How to Prevent ConcurrentModificationException in Java Collections
Java Architect Essentials
Java Architect Essentials
Oct 18, 2022 · Fundamentals

Common Pitfalls When Using Java List Implementations and How to Avoid Them

This article systematically examines ten typical pitfalls encountered when converting arrays to lists, performing add/remove operations, using subList, handling memory consumption, and working with thread‑safe collections such as CopyOnWriteArrayList in Java, and provides concrete code‑level solutions and performance recommendations.

ArrayListCopyOnWriteArrayListLinkedList
0 likes · 20 min read
Common Pitfalls When Using Java List Implementations and How to Avoid Them
Java High-Performance Architecture
Java High-Performance Architecture
Oct 17, 2022 · Backend Development

10 Hidden Pitfalls of Java List Implementations and How to Avoid Them

This article examines common traps when using Java List structures such as Arrays.asList, ArrayList, LinkedList, and CopyOnWriteArrayList, explains why they occur, and provides practical solutions—including proper conversion, avoiding unsupported operations, handling subList references, and mitigating memory and concurrency issues.

ArrayListArrays.asListCopyOnWriteArrayList
0 likes · 19 min read
10 Hidden Pitfalls of Java List Implementations and How to Avoid Them
Java Backend Technology
Java Backend Technology
Sep 19, 2022 · Fundamentals

Why Your Java List Operations May Fail: Hidden Pitfalls and Fixes

This article reveals common pitfalls when using Java List implementations—such as Arrays.asList with primitive arrays, unsupported add/remove operations, side‑effects on the original array, subList memory leaks, LinkedList performance myths, and CopyOnWriteArrayList’s memory and iterator quirks—while providing practical solutions and best‑practice recommendations.

ArrayListCollectionsCopyOnWriteArrayList
0 likes · 19 min read
Why Your Java List Operations May Fail: Hidden Pitfalls and Fixes
Cognitive Technology Team
Cognitive Technology Team
May 14, 2022 · Backend Development

Copy‑On‑Write Strategy and Its Implementation in Java's CopyOnWriteArrayList

The article explains the copy‑on‑write (COW) concurrency strategy, its suitability for read‑heavy scenarios, and demonstrates how Java implements COW with CopyOnWriteArrayList and CopyOnWriteArraySet, including volatile array handling, write‑locking, snapshot reads, and iterator behavior.

Backend DevelopmentCopy-on-WriteCopyOnWriteArrayList
0 likes · 7 min read
Copy‑On‑Write Strategy and Its Implementation in Java's CopyOnWriteArrayList
Sanyou's Java Diary
Sanyou's Java Diary
Apr 15, 2022 · Backend Development

Why Use Read‑Write Locks When Java Already Offers Thread‑Safe Collections?

This article examines the internal workings of Java's CopyOnWriteArrayList, explains why its weak consistency still necessitates read‑write locks in read‑heavy scenarios, and compares exclusive locks with read‑write locks to achieve strong data consistency without sacrificing performance.

CopyOnWriteArrayListJavaReadWriteLock
0 likes · 11 min read
Why Use Read‑Write Locks When Java Already Offers Thread‑Safe Collections?
Selected Java Interview Questions
Selected Java Interview Questions
Jun 18, 2021 · Fundamentals

Understanding CopyOnWriteArrayList, Vector, and SynchronizedList in Java Concurrency

This article explains the copy‑on‑write optimization, compares Vector, Collections.synchronizedList and CopyOnWriteArrayList, analyzes their fail‑fast behavior, shows how CopyOnWriteArrayList is implemented and iterated, and presents performance benchmarks highlighting their strengths and weaknesses.

CollectionsCopyOnWriteArrayListJava
0 likes · 14 min read
Understanding CopyOnWriteArrayList, Vector, and SynchronizedList in Java Concurrency
Selected Java Interview Questions
Selected Java Interview Questions
Jun 4, 2021 · Fundamentals

Why Removing Elements During forEach on an ArrayList Triggers ConcurrentModificationException and How to Fix It

The article explains that deleting elements from an ArrayList inside a forEach loop can cause a ConcurrentModificationException because the iterator's expected modification count diverges from the actual count, and it shows correct ways to remove items safely using an explicit Iterator or a CopyOnWriteArrayList.

ArrayListConcurrentModificationExceptionCopyOnWriteArrayList
0 likes · 5 min read
Why Removing Elements During forEach on an ArrayList Triggers ConcurrentModificationException and How to Fix It
Programmer DD
Programmer DD
May 21, 2021 · Backend Development

ThreadLocal & ConcurrentHashMap: Hidden Bugs in Java Concurrency

This article examines common misconceptions when using Java concurrency utilities such as ThreadLocal, ConcurrentHashMap, and CopyOnWriteArrayList, demonstrates real‑world bugs caused by thread reuse and improper atomic operations, and provides practical solutions—including explicit cleanup, proper locking, and high‑performance alternatives like computeIfAbsent and LongAdder—to ensure thread‑safe and efficient code.

ConcurrentHashMapCopyOnWriteArrayListJava
0 likes · 12 min read
ThreadLocal & ConcurrentHashMap: Hidden Bugs in Java Concurrency
Top Architect
Top Architect
Feb 10, 2021 · Backend Development

Understanding Thread Safety Issues in Java ArrayList and How to Fix Them

This article explains why Java's ArrayList is not thread‑safe, illustrates the two main concurrency problems—array index out‑of‑bounds and element overwriting—through source‑code analysis and multithreaded examples, and presents several practical solutions such as synchronized wrappers, explicit locking, CopyOnWriteArrayList and ThreadLocal.

ArrayListCollectionsCopyOnWriteArrayList
0 likes · 11 min read
Understanding Thread Safety Issues in Java ArrayList and How to Fix Them
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
Selected Java Interview Questions
Selected Java Interview Questions
Dec 26, 2020 · Backend Development

Thread Reuse Pitfalls, ThreadLocal Misuse, and Proper Use of ConcurrentHashMap and CopyOnWriteArrayList

This article explains how thread reuse in a Tomcat thread pool can cause user‑information leakage when ThreadLocal is misused, analyzes the non‑atomic behavior of ConcurrentHashMap operations, demonstrates performance differences between locking and atomic methods, and warns against inappropriate use of CopyOnWriteArrayList in high‑write scenarios.

ConcurrentHashMapCopyOnWriteArrayListJava concurrency
0 likes · 13 min read
Thread Reuse Pitfalls, ThreadLocal Misuse, and Proper Use of ConcurrentHashMap and CopyOnWriteArrayList
Programmer DD
Programmer DD
Oct 21, 2020 · Backend Development

Mastering CopyOnWrite in Java: Boost Concurrency Performance

This article explains the CopyOnWrite optimization strategy, details the internal workings of CopyOnWriteArrayList and a custom CopyOnWriteMap in Java, outlines key implementation points, typical use cases, advantages over Vector, and discusses memory and consistency trade‑offs.

Backend DevelopmentCopyOnWriteCopyOnWriteArrayList
0 likes · 10 min read
Mastering CopyOnWrite in Java: Boost Concurrency Performance
FunTester
FunTester
Feb 26, 2020 · Fundamentals

Why Thread‑Safe Collections Still Fail with Non‑Thread‑Safe Objects in Java

Through a series of Java demos, this article examines how storing non‑thread‑safe objects inside thread‑safe collections like ConcurrentHashMap or CopyOnWriteArrayList can still cause concurrency bugs, explains the underlying remove() implementation, and shows how switching to a thread‑safe Vector resolves the issue.

CollectionsConcurrentHashMapCopyOnWriteArrayList
0 likes · 8 min read
Why Thread‑Safe Collections Still Fail with Non‑Thread‑Safe Objects in Java
Big Data Technology & Architecture
Big Data Technology & Architecture
Feb 15, 2019 · Backend Development

Understanding CopyOnWriteArrayList: Introduction, Principles, API, and Source‑Code Analysis

This article introduces Java's CopyOnWriteArrayList, explains its dynamic‑array and thread‑safety mechanisms, lists the most important methods, provides detailed source‑code walkthroughs for constructors, add, get, remove and iterator implementations, and demonstrates its behavior with a multithreaded example compared to ArrayList.

CollectionsCopyOnWriteArrayListJava
0 likes · 14 min read
Understanding CopyOnWriteArrayList: Introduction, Principles, API, and Source‑Code Analysis
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Oct 17, 2018 · Backend Development

Understanding CopyOnWriteArrayList in Java: Implementation, Principles, and Comparison with ArrayList

CopyOnWriteArrayList is a thread‑safe variant of ArrayList that achieves read‑write separation by copying the underlying array on each mutative operation, using a ReentrantLock for writes, making it ideal for read‑heavy, write‑light scenarios, and it differs from ArrayList in safety, performance, and concurrency behavior.

CopyOnWriteArrayListData StructuresJava
0 likes · 5 min read
Understanding CopyOnWriteArrayList in Java: Implementation, Principles, and Comparison with ArrayList
Java Captain
Java Captain
Feb 11, 2018 · Backend Development

Analyzing Java Concurrency Models: CopyOnWriteArrayList, ConcurrentHashMap, and LinkedBlockingQueue

This article examines three Java concurrency implementations—CopyOnWriteArrayList, ConcurrentHashMap, and LinkedBlockingQueue—explaining their underlying principles, code structures, and how they achieve thread‑safe read/write operations using techniques such as copy‑on‑write, CAS, and separate locks.

CASConcurrentHashMapCopyOnWriteArrayList
0 likes · 13 min read
Analyzing Java Concurrency Models: CopyOnWriteArrayList, ConcurrentHashMap, and LinkedBlockingQueue