?
-
If I were to do this:
public void method() {
Container parent = getParent();
:::
:::
:::
parent.callMethod(...);
:::
:::
:::
:::
parent.callAnotherMethod(...);
:::
:::
}
and if another thread were to change the parent, will the above fail
since the method is not synchronized?
Or should I just leave it that way rather than change it to
getParent().callMethod(...) everytime...but doing so is of no use since
if the parent changes midway, the method's objective will not be met
since it requires that the parent be the same throughout the method's scope?
public void method() {
Container parent = getParent();
:::
:::
:::
parent.callMethod(...);
:::
:::
:::
:::
parent.callAnotherMethod(...);
:::
:::
}
and if another thread were to change the parent, will the above fail
since the method is not synchronized?
Or should I just leave it that way rather than change it to
getParent().callMethod(...) everytime...but doing so is of no use since
if the parent changes midway, the method's objective will not be met
since it requires that the parent be the same throughout the method's scope?