Companion code for the ankurm.com post "Top 40 Java Collections Interview Questions (HashMap Internals to Fail-Fast Iterators)". Verified against JDK 25's own HashMap source (TREEIFY_THRESHOLD=8, UNTREEIFY_THRESHOLD=6, MIN_TREEIFY_CAPACITY=64), with every claim backed by a committed docs/output/*.txt transcript from a real run. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01YXCrLgRKFgCh9RHKW8xaqJ
8 lines
437 B
Plaintext
8 lines
437 B
Plaintext
ConcurrentHashMap's iterator is weakly consistent: it never throws CME
|
|
======================================================================
|
|
|
|
map before: {0=v0, 1=v1, 2=v2, 3=v3, 4=v4}
|
|
entries visited during iteration (original 5, plus possibly some newly-added ones): 19
|
|
map after: 24 entries total
|
|
ConcurrentModificationException thrown: false
|
|
(weakly consistent: may or may not reflect the mutation, but is guaranteed never to throw) |