private static Callback callback;
public Foo()
{
super(getCallback());
}
private static Callback getCallback()
{
callback = new Callback();
return callback;
}
The Foo () constructor can potentially be called from multiple threads. I care about the private static "callback" field and the static "getCallback ()" method.
As you can see, every time 'getCallback ()' is called, it assigns a new value to the static field 'callback'.
I assume that it is not thread safe because the static keyword is always bound to the class and not to the instance, so this means that the static Foo callback response could potentially be overwritten by another thread that creates another Foo (). Is it correct?
Please correct me if I am wrong. Thanks!
EDIT: " " - , . , Foo , , " ", .