Код: Выделить всё
@JCStressTest
@Outcome(id = "1, 1", expect = Expect.ACCEPTABLE, desc = "ordered")
@Outcome(id = "0, 1", expect = Expect.ACCEPTABLE, desc = "ordered")
@Outcome(id = "1, 0", expect = Expect.ACCEPTABLE, desc = "reordered")
@Outcome(id = "0, 0", expect = Expect.ACCEPTABLE, desc = "ordered")
@State
public class TestJUC {
private int x;
public TestJUC() {}
@Actor
public void actor1() {
x = 1;
}
@Actor
public void actor2(II_Result r) {
1.int a = x;
2.r.r1 = a;
3.int b = x;
4.r.r2 = b;
}
}
Возможна следующая ситуация. .
int b = x;
int a = x;
r.r1 = a;
r.r2 = b;
Эта ситуация может привести к (1,0), но после тестирования jctress такого результата не произошло. Почему это?
Подробнее здесь: https://stackoverflow.com/questions/790 ... mory-model
Мобильная версия