After reading my core Java interview questions, my friend and a colleague Mike Polyak said that I should include the following advanced interview question on Java threads synchronization:
In the class below, is method getIt() thread safe and why?
public class X {
private long myVar;
public void setIt(long var){
myVar = var;
}
public long getIt() {
return myVar;
}
}
If you have an idea what “s the right answer is, feel free to write it in the Comments section of this blog. I “ll publish the answer in a week in this very blog, so stay tuned hellip;
Happy Independence Day for those who celebrates it!