Skip to content

Commit 9333ebc

Browse files
committed
Add a note about linearizable reads to Dc.9
1 parent 79f0136 commit 9333ebc

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

README.md

+9-3
Original file line numberDiff line numberDiff line change
@@ -428,9 +428,15 @@ Similarly to what is noted in the previous item, justification for a lazily init
428428
`volatile` could be omitted if the lazy initialization pattern itself is identified, according to
429429
[Dc.4](#name-patterns). When `volatile` on a field is needed to ensure *safe publication* of
430430
objects written into it (see [JCIP 3.5] or [here](
431-
https://shipilev.net/blog/2014/safe-public-construction/#_safe_publication)), then just mentioning
432-
"safe publication" in the Javadoc comment for the field is sufficient, it's not needed to elaborate
433-
the semantics of `volatile` which ensure the safe publication.
431+
https://shipilev.net/blog/2014/safe-public-construction/#_safe_publication)) or
432+
[linearizability of values observed by reader threads](#safe-local-dcl), then just mentioning
433+
"safe publication" or "linearizable reads" in the Javadoc comment for the field is sufficient, it's
434+
not needed to elaborate the semantics of `volatile` which ensure the safe publication or the
435+
linearizability.
436+
437+
By extension, this item also applies when an `AtomicReference` (or a primitive atomic) is used
438+
instead of raw `volatile`, along with the consideration about [unnecessary
439+
atomic](#redundant-atomics) which might also be relevant in this case.
434440

435441
<a name="plain-field"></a>
436442
[#](#plain-field) Dc.10. Is it explained in the **Javadoc comment for each mutable field in a

0 commit comments

Comments
 (0)