Re: Newbie Learning Threading
- From: Jon Skeet [C# MVP] <skeet@xxxxxxxxx>
- Date: Thu, 26 May 2005 22:11:06 +0100
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
.
- Follow-Ups:
- Re: Newbie Learning Threading
- From: Cor Ligthert
- Re: Newbie Learning Threading
- References:
- Newbie Learning Threading
- From: Bishop
- Re: Newbie Learning Threading
- From: Cor Ligthert
- Re: Newbie Learning Threading
- From: Jon Skeet [C# MVP]
- Re: Newbie Learning Threading
- From: Cor Ligthert
- Newbie Learning Threading
- Prev by Date: Re: Handling thousands of TCP socket connections
- Next by Date: Re: Newbie Learning Threading
- Previous by thread: Re: Newbie Learning Threading
- Next by thread: Re: Newbie Learning Threading
- Index(es):
Relevant Pages
|