Skip to content

Commit 7e82ba1

Browse files
dreis2211Roger Riggs
authored and
Roger Riggs
committedOct 8, 2020
8254146: Avoid unnecessary volatile write on new AtomicBoolean(false)
Reviewed-by: redestad, rriggs, chegar
1 parent 6d13c76 commit 7e82ba1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed
 

‎src/java.base/share/classes/java/util/concurrent/atomic/AtomicBoolean.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ public class AtomicBoolean implements java.io.Serializable {
6868
* @param initialValue the initial value
6969
*/
7070
public AtomicBoolean(boolean initialValue) {
71-
value = initialValue ? 1 : 0;
71+
if (initialValue) {
72+
value = 1;
73+
}
7274
}
7375

7476
/**

0 commit comments

Comments
 (0)
Please sign in to comment.