Double checked locking Article

后端 未结 10 668
别那么骄傲
别那么骄傲 2020-12-09 20:06

I was reading this article about \"Double-Checked locking\" and out of the main topic of the article I was wondering why at some point of the article the author uses the nex

10条回答
  •  半阙折子戏
    2020-12-09 20:42

    Since Java 5, you can make double-checked locking work by declaring the field volatile.

    See http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html for a full explanation.

提交回复
热议问题