跳转到内容

欢迎来到Riguz的小站!这是一个私人wiki,用来记录一些我的笔记。

Java this escape:修订间差异

来自WHY42
Riguz​(留言 | 贡献)
无编辑摘要
Riguz​(留言 | 贡献)
小 Riguz移动页面Java:this逸出至Java this escape,不留重定向
 
(没有差异)

2023年12月19日 (二) 06:55的最新版本

public FinalFieldExample() { // bad!
  x = 3;
  y = 4;
  // bad construction - allowing this to escape
  global.obj = this;
}

then threads that read the reference to this from global.obj are not guaranteed to see 3 for x.