4

for example,

boolean[] booleanArray = new boolean[10];

I just want to make sure each single read and write is volatile.

Should I do: (I am not sure if the volatile is applied to the array or each boolean)

volatile boolean[] booleanArray = new boolean[10];
user1947415
  • 933
  • 4
  • 14
  • 31
  • Well ... The `volatile` is applied to the variable (in your wording: to the array). – Seelenvirtuose Nov 20 '18 at 19:11
  • There is an [`AtomicBoolean`](https://docs.oracle.com/javase/8/docs/api/index.html?java/util/concurrent/atomic/AtomicBoolean.html), but [this](https://stackoverflow.com/questions/19379548/why-there-is-no-atomicbooleanarray-datatype-in-java) should explain why there is no `AtomicBooleanArray`. – deHaar Nov 20 '18 at 19:13

0 Answers0