Re: WaitForSingleObject() will not deadlock



Mutexes are not autoreset or manual reset; you are confusing them with events.

The OP is clueless about synchronization. All solutions relating to using mutexes,
semaphores, or events will be incorrect answers to his problem.
joe

On Sat, 30 Jun 2007 23:39:48 +0800, ajk <ak@xxxxxxxxxxxx> wrote:

On Sat, 30 Jun 2007 00:31:03 -0700, Frank Cusack <fcusack@xxxxxxxxxxx>
wrote:

Code like this

if (WaitForSingleObject(mutex, INFINITE) == WAIT_OBJECT_0)
AfxMessageBox("acquired", ID_OK);
if (WaitForSingleObject(mutex, INFINITE) == WAIT_OBJECT_0)
AfxMessageBox("acquired", ID_OK);

displays 2 alert boxes. How do I make this deadlock instead?

-frank

how did you create your mutex? was it autoreset or manual (my bet).

if you want to "deadlock" you need to call it from two threads, not
after each other - probably what is happening, once the mutex signaled
both WaitForSingleObject fires.
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.