volatile int ready; // Initially 0, with VarHandle READY
int dinner; // mode does not matter here
Thread 1 | Thread 2
dinner = 17; | if (READY.getAcquire(this) == 1)
READY.setRelease(this, 1); | int d = dinner; // sees 17
< /code>
Тем не менее, мне не удалось воспроизвести исходные результаты: < /p>
Код: Выделить всё
Java Concurrency Stress Tests
---------------------------------------------------------------------------------
...
RESULT SAMPLES FREQ EXPECT DESCRIPTION
0 462,012 1.69% Interesting
17 26,856,279 98.31% Interesting
...
RESULT SAMPLES FREQ EXPECT DESCRIPTION
0 1,027,953,599 44.29% Interesting
17 1,292,906,829 55.71% Interesting
...
У меня было полное представление о выходе на Infomation на Pastebin (https://pastebin.com/feif5xpg)
мой код является следующим:
Подробнее здесь: https://stackoverflow.com/questions/796 ... de-of-j9mm