Is reordering of instance initialization and assignment to a shared variable possible?

后端 未结 2 627
深忆病人
深忆病人 2021-01-02 02:23

I was reading an essay, which actually talks about double-checked locking, but I\'m surprised about an even more basic failure in the code presented as examples. It is state

2条回答
  •  -上瘾入骨i
    2021-01-02 03:16

    Instance initialization reordering by JIT compiler IS possible even under x86. However, it is somewhat tricky to write code that can trigger such reordering. On how to reproduce such reordering, see my question:

    Is there any instruction reordering done by the Hotspot JIT compiler that can be reproduced?

提交回复
热议问题