Hello!
In second example we consider such 5th step:
int read4 = read3.x;
is executed by thread1 andread4
is set to3
.
While on the 2d step there isread3 = obj2
.
obj2.x
orread3
are nowhere changed so how is it possible thatread4
becomes 3? I’m sure thatread4
stays 0.
Course: https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews
Lesson: Reordering Effects - Java Multithreading for Senior Engineering Interviews