Do I understand right that end of constructor is not a happens - before relation in Java? Is it possible, that code below with threads A and B not been synchronized somehow could throw a NullPointerException ?
// Shared reference declaration
public MyClass val;
// Class declaration
public class MyClass {
public Object object;
public MyClass() {
object = new Object();
}
}
// Using in thread A
MyClass loc = new MyClass();
val = loc;
// Using in thread B
if(val != null) {
val.object.hashCode(); // IMO could throw NPE
}