Skip to content

Commit a6d4ca5

Browse files
authored
Expand RC.3
1 parent 7d7064d commit a6d4ca5

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,10 +390,14 @@ http://cs.oswego.edu/pipermail/concurrency-interest/2018-September/016526.html).
390390

391391
<a name="unsafe-concurrent-iteration"></a>
392392
[#](#unsafe-concurrent-iteration) RC.3. A variation of the previous item: isn’t a non-thread-safe
393-
collection such as `HashMap` or `ArrayList` **iterated outside of a critical section**, while it can
393+
collection such as `HashMap` or `ArrayList` **iterated outside of a critical section**, while it may
394394
be modified concurrently? This could happen by accident when an `Iterable`, `Iterator` or `Stream`
395395
over a collection is returned from a method of a thread-safe class, even though the iterator or
396-
stream is created within a critical section.
396+
stream is created within a critical section. Returning unmodifiable collection views like
397+
`Collections.unmodifiableList()` from getters wrapping collection fields that may be modified
398+
concurrently is subject to the same problem. If the collection is relatively small, it should be
399+
copied entirely, or a copy-on-write collection (see [Sc.3](#non-blocking-collections)) should be
400+
used instead of a non-thread-safe collection.
397401

398402
Like the previous item, this one applies to growing ArrayLists too.
399403

0 commit comments

Comments
 (0)