Re: WaitForSingleObject() failing?
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Fri, 06 Jan 2006 17:17:58 -0500
How so? The way it works is that the last thing the thread does before returning from the
thread is a PostMessage. Since nothing accesses the thread after that point, and it
accesses nothing else, the only issue is whether or not the process completes and does
ExitProcess before the thread actually finishes. As far as I can tell, all required
conditions are met for clean thread termination.
joe
On Fri, 06 Jan 2006 15:53:37 -0600, "Doug Harrison [MVP]" <dsh@xxxxxxxx> wrote:
>On Fri, 06 Jan 2006 16:08:17 -0500, Joseph M. Newcomer
><newcomer@xxxxxxxxxxxx> wrote:
>
>>Yes. The issue is whether you use a synchronous join or an asynchronous join. I have
>>tended more and more in recent years to using an asynchronous join because I don't get
>>caught even inadvertently in a situation where there can be a thread deadlock.
>>
>>In one case, I had some variable number of threads, n, in the program. All I did was keep
>>a reference count of outstanding threads, and when OnClose happened, I deferred executing
>>the parent class OnClose until the reference count of outstanding threads had gone to
>>zero. So all OnClose did was simply initiate thread shutdown and return; the "join" was
>>when the outstanding thread count went to zero.
>
>Unless you WaitForSingleObject (or use one of its cousins), you still have
>a race condition. Finding a reference count equal to zero is not a
>substitute for finding a thread handle signaled.
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- Follow-Ups:
- Re: WaitForSingleObject() failing?
- From: Doug Harrison [MVP]
- Re: WaitForSingleObject() failing?
- From: Alexander Grigoriev
- Re: WaitForSingleObject() failing?
- References:
- WaitForSingleObject() failing?
- From: Davinder
- Re: WaitForSingleObject() failing?
- From: Davinder
- Re: WaitForSingleObject() failing?
- From: Joseph M . Newcomer
- Re: WaitForSingleObject() failing?
- From: Alexander Grigoriev
- Re: WaitForSingleObject() failing?
- From: Joseph M . Newcomer
- Re: WaitForSingleObject() failing?
- From: Doug Harrison [MVP]
- Re: WaitForSingleObject() failing?
- From: Joseph M . Newcomer
- Re: WaitForSingleObject() failing?
- From: Doug Harrison [MVP]
- WaitForSingleObject() failing?
- Prev by Date: Re: CAsyncsocket derived class being run as a thread
- Next by Date: .NET IDE Proprocessor definitions macros not defined - Release build only
- Previous by thread: Re: WaitForSingleObject() failing?
- Next by thread: Re: WaitForSingleObject() failing?
- Index(es):
Relevant Pages
|