File tree 1 file changed +9
-3
lines changed
1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -428,9 +428,15 @@ Similarly to what is noted in the previous item, justification for a lazily init
428
428
` volatile ` could be omitted if the lazy initialization pattern itself is identified, according to
429
429
[ Dc.4] ( #name-patterns ) . When ` volatile ` on a field is needed to ensure * safe publication* of
430
430
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.
434
440
435
441
<a name =" plain-field " ></a >
436
442
[ #] ( #plain-field ) Dc.10. Is it explained in the ** Javadoc comment for each mutable field in a
You can’t perform that action at this time.
0 commit comments