并发代码中赋值运算符的返回值
2022-09-01 09:58:09
给定以下类:
class Foo {
public volatile int number;
public int method1() {
int ret = number = 1;
return ret;
}
public int method2() {
int ret = number = 2;
return ret;
}
}
并且给定多个线程在同一实例上调用并发,对formula1()的调用是否可以返回除1之外的任何内容?method1()
method2()
Foo