Safe publication through final

前端 未结 3 1483
孤独总比滥情好
孤独总比滥情好 2020-12-07 03:22

Even after going though this, I am still not clear about how usage of final causes safe publication in the below code. Can someone give an easy-to-understand explanation.

3条回答
  •  遥遥无期
    2020-12-07 03:57

    You can refer to JSL Final field or the object reachable through a final reference can't be reordered with the initial load of a reference to that object. It is visible to all other threads after its construction.

提交回复
热议问题