Using variable or using direct method call



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?
.




Relevant Pages

  • Re: Using variable or using direct method call
    ... public void method() { ... and if another thread were to change the parent, ... two threads called callMethod() both of which change the members of parent. ...
    (comp.lang.java.programmer)
  • Re: ActionListener scoping
    ... an ActionListener, or return anything, or modify local method ... with its parent method. ... accessable by the method since the class scope is the method's parent ...
    (comp.lang.java.help)
  • Re: define_method in inheritance
    ... This opens up the scope of a given class so any other class could add ... into a parent and then invoke it on a child would the new method be ... David A. Black / Ruby Power and Light, ...
    (comp.lang.ruby)
  • Re: limiting search scope
    ... index server. ... Here's what I have set up to filter my 'parent' folder ... index service and to limit the scope of the search. ...
    (microsoft.public.inetserver.indexserver)
  • Re: Object scope issue...
    ... So, the "update" method on the Parent class, inserts or updates parent ... What I was doing in my "Save" command button code was setting the parent ... I only do a database update. ... Is this typically how one would control an objects scope - by setting as ...
    (microsoft.public.dotnet.languages.vb)