Java this escape:修订间差异
建立內容為「<syntaxhighlight lang="java"> public FinalFieldExample() { // bad! x = 3; y = 4; // bad construction - allowing this to escape global.obj = this; } </synt…」的新頁面 |
无编辑摘要 |
||
第9行: | 第9行: | ||
then threads that read the reference to this from global.obj are not guaranteed to see 3 for x. | then threads that read the reference to this from global.obj are not guaranteed to see 3 for x. | ||
[[Category: | [[Category:Concurrency]] |
2021年5月1日 (六) 13:53的版本
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.