Are 64 bit assignments in Java atomic on a 32 bit machine?

前端 未结 4 952
轮回少年
轮回少年 2020-12-02 16:12

If I have code like this -

long x;
x  = 0xFFFFFFFFL;


If i run this code on a 32 bit machine is it guaranteed to be atomic or is it po

4条回答
  •  -上瘾入骨i
    2020-12-02 16:44

    Section 8.4 of the Java Virtual Machine specification states that a double or long that is not declared volatile is treated as two 32-bit variables for load, store, read and write operations.

    Furthermore, the manner of encoding and the order of the two 32-bit operations is not defined.

    The spec does encourage implementations to make the operation atomic but they do not require it.

提交回复
热议问题