Tagged articles
CopyOnWriteArrayList
19 articles · Page 1 of 1

DabaoshiAug 18, 2026 · Backend Development
This article explains why HashMap isn’t thread‑safe, how Hashtable’s single lock hurts performance, and walks through the evolution from JDK 1.7 segment locks to JDK 1.8’s CAS‑plus‑synchronized bucket locking, including lock‑free size counting and a comparison with CopyOnWriteArrayList for read‑heavy scenarios.
ConcurrencyConcurrentHashMapCopyOnWriteArrayList
0 likes · 17 min read

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.
ConcurrentHashMapConcurrentModificationExceptionCopyOnWriteArrayList
0 likes · 7 min read

The article explains the Copy‑On‑Write (COW) technique, its read‑write separation design, step‑by‑step flow, practical demos, Java's CopyOnWriteArrayList implementation, and MySQL InnoDB MVCC usage, while also discussing its performance benefits and inherent limitations.
COWConcurrencyCopyOnWriteArrayList
0 likes · 21 min read

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.
ConcurrencyCopyOnWriteArrayListLinkedList
0 likes · 20 min read

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.
Arrays.asListCopyOnWriteArrayListJava
0 likes · 19 min read

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.
CopyOnWriteArrayListJavaLinkedList
0 likes · 19 min read

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.
ConcurrencyCopyOnWriteArrayListJava
0 likes · 7 min read

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

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.
CopyOnWriteArrayListJavaThreadSafety
0 likes · 14 min read

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.
ConcurrentModificationExceptionCopyOnWriteArrayListJava
0 likes · 5 min read

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

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.
ConcurrencyCopyOnWriteArrayListJava
0 likes · 11 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 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

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.
CopyOnWriteCopyOnWriteArrayListJava
0 likes · 10 min read

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.
ConcurrencyConcurrentHashMapCopyOnWriteArrayList
0 likes · 8 min read

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.
ConcurrencyCopyOnWriteArrayListJava
0 likes · 14 min read

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.
ConcurrencyCopyOnWriteArrayListJava
0 likes · 5 min read

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
