Re: Newbie Learning Threading

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Cor Ligthert <notmyfirstname@xxxxxxxxx> wrote:
> >> Your error is that you place your address-holder global, so every thread
> >> uses
> >> the same address, and therefore only the last one exist.
> >
> > No, all the threads would still be running - just because one
> > variable's value is overwritten doesn't stop the thread from existing!
> > It's just that only the last thread would still have an event handler
> > hooked up
>
> I don't understand what this contributes to the question from the OP, he
> told that he needed it for learning. This was in my opinion the most simple
> way of telling it.

But I don't think it gets across the really important bit - which is
that when you replace the value of the "variable" (which has been
turned into a property by the compiler) the event handlers are
automatically removed.

> One more complete right answer could have been. Every object that you
> instance has, when you instance it, the same address. At the end of the
> procedure, where you instance them, the previous goes out of scope. This
> means that only the last exist.

That would be untrue though.

> However seeing the code from the OP, was my opinion that he would understand
> that as well with my short hint. This is a newsgroup you know, not an
> academically forum.

But I believe your answer was neither right nor helpful.

> I am not even sure of your answer is right because at the end of the
> instancing procedure the previous object goes completely out of scope.

No, the newly created thread still has a reference to it - it's running
an instance method of the object.

--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
.



Relevant Pages

  • Re: Newbie Learning Threading
    ... However seeing the code from the OP, was my opinion that he would understand ... that as well with my short hint. ... instancing procedure the previous object goes completely out of scope. ...
    (microsoft.public.dotnet.general)
  • RE: rules of engagement scope
    ... Realizing it's just an opinion you've offered, ... Subject: rules of engagement scope ... public disclosure, why is that different than FRAUD? ... MHO is that pen-tests are as important as ...
    (Pen-Test)
  • Re: Cross-Browser Mouse Event Handling
    ... The approach of assigning an event handler via script separates ... After all, they should not be written to use their augmented scope chains as the augmentation itself is not guaranteed to happen at all, and is inconsistent between browsers where it does happen, and simultaneously that code should be written with the anticipation of the worst-case augmentation. ...
    (comp.lang.javascript)
  • Re: Oscilloscope for testing CB?
    ... SSB isn't just "filted AM" ... >> not having a 'scope is not an end-all when it comes to fixing radios. ... >> then IT IS MY OPINION he doesnt know how to use a 'scope. ... If the RSGB has less members it has less income from members therefore less ...
    (uk.rec.radio.cb)
  • Re: How long for AP160?
    ... Mark D wrote: ... yours, but you must spend it, and buy a scope with it. ... True Vlad, and I agree wholeheartedly with you opinion. ...
    (sci.astro.amateur)