I have a class that serves as a delegate to another.
public class Delegate {
private AnotherClass ac;
public void delegateCall() {
this.ac.actualCall();
}
public void setAC(AnotherClass ac) {
this.ac = ac;
}
}
What are the ramifications if I have lots of threads calling delegateCall()
and another thread calls setAC()
? My assumption is that some of the threads calling delegateCall()
would get access to the ac instance before it was set and some would get access to it after it was set. In my particular application, it does not matter which instance each thread gets.
My question: Is there any underlying synchronization that may happen within the JVM that might cause the threads calling delegateCall() to block?