Writing long and double is not atomic in Java?

前端 未结 6 1590
甜味超标
甜味超标 2020-12-02 18:37

Reading and writing of a single variable is atomic (language guarantee!), unless the variable is of type long or double.

I was reading

6条回答
  •  独厮守ぢ
    2020-12-02 19:11

    It's not atomic because it's a multiple-step operation at the machine code level. That is, longs and doubles are longer than the processor's word length.

提交回复
热议问题