Consider the following example:
Thread 1:
data.a = 1;
synchronized (sth) {
shared = data;
}
Thread 2:
synchronized (sth) {
assertEquals(1, shared.a);
}
Assume that the code in Thread 2 gets executed after the code for Thread 1.
Is the assert guaranteed to succeed, ie. does the memory barrier inherent to the lock release in thread #1 extend to the assignment of the value 1 before and outside of the synchronized block?