Writing long and double is not atomic in Java?

前端 未结 6 1606
甜味超标
甜味超标 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条回答
  •  Happy的楠姐
    2020-12-02 19:12

    Java long and double are not atomic in 32 bit machines, but atomic in 64 bit machines with some of the 64 bit JVMs. why its dependant on machine bit length? Because 32 bit machine needs two writes for long(as long is 64 bit). Read this for detailed info.

提交回复
热议问题