Re: Using variable or using direct method call



- wrote:

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

Depends on what you want and what you consider "fail".

Basically, you are talking about a situation where the locally stored
'parent' and the result of getParent() is no longer the same. That
means that
parent.callAnotherMethod()
and
getParent().callAnotherMethod()
will call on different objects. The first variant will call on the
container that was the parent when the method started. The second
variant will call on the container that is the parent right now. I
can't tell you which of the objects you _want_ to call on.

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

If you want to call on the same container object throughout your
method, _and_ you want that object to be the actual parent-container,
then you should synchronize on something.

--
Johan Utne Poppe
.



Relevant Pages

  • Re: Shutting down a service
    ... >When one of our services fails on our HPUNIX box we want to be able to ... by an external network-delivered command? ... Write a parent process that will ... is that the process that may fail should not daemonize itself, ...
    (comp.sys.hp.hpux)
  • Re: Can we continue to call ourselves a civilised country?
    ... to ascertain the reason, and if the parent is at fault measures to ... take into care any child that failed. ... *Any* parent can educate a child up to the stage of early high school. ... There may be perfectly valid reasons why a minority of children fail ...
    (uk.legal)
  • Re: DTS package Precedence not working
    ... I guess that means that you cannot easily have a child process which both ... has on-error processing, but which you also want to signal a fail to a parent ... if any other tasks fail. ...
    (microsoft.public.sqlserver.dts)
  • Re: Setting parent form property to Visible = False
    ... Sorry Rick: ... thus the parent (the Actual form that I am on ... I've tried the various options and they fail. ... What's the syntax? ...
    (microsoft.public.access.formscoding)
  • Re: Crash-Kurs Container/Pageframe
    ... Danke auch für den Tipp "Parent", ... >Man könnte den Container u.U. weglassen, ... aber da können dann auch nur Buttons rein. ... mal wieder Deine Eltern ...
    (microsoft.public.de.fox)