Re: WaitForSingleObject() failing?
- From: "Doug Harrison [MVP]" <dsh@xxxxxxxx>
- Date: Fri, 06 Jan 2006 15:53:37 -0600
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.
--
Doug Harrison
Visual C++ MVP
.
- Follow-Ups:
- Re: WaitForSingleObject() failing?
- From: Joseph M . Newcomer
- 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
- WaitForSingleObject() failing?
- Prev by Date: Re: Venting on .NET
- Next by Date: Drawing MFC Dialog in ActiveX Container
- Previous by thread: Re: WaitForSingleObject() failing?
- Next by thread: Re: WaitForSingleObject() failing?
- Index(es):
Relevant Pages
|