Consider 2 threads and an array int[] values
.
The first thread is performing:
synchronized (values) {
values[i] = 58;
}
while the second thread is performing:
if (values[i] == 58) {
}
outside a synchronized
block.
If the first thread first performs values[i]= 58
, is it guaranteed that if the second threads executes slightly later, that the if
of the second thread reads 58
even though the second thread reads values[i]
outside a synchronized
block?