Question: Thread A: set the variable m\_bPaused and the m\_pPauseEvent is a semaphore object which provides wait() and set() interface.
Thread A call this to pause:

```
PausePlay(){
    m_bPaused = true;           // A1

    m_pPauseEvent->Wait(0);     //A2 wait for the B thread is enter to the waiting
}

```

Thread B:

```
    if (m_bPaused)
   {
       m_pPauseEvent->Set();    //B1
       m_pPauseEvent->Wait(0);  //B2 0 wait forever 
   }

```

And call Thread A to continue Thread B:

```
    m_bPaused = false;    //A3

    m_pPauseEvent->Set(); //A4 

```

When I pause, I wait until the B1 is executed.Thread A returns.Will here be dead lock? when I call the continue in Thread A,and run to A3. In the mean time thread B is still beteen B1 and and B2, then thead A finish the row m\_pPauseEvent->Set(). Thread B will never received the signal sent by A4.Dead lock! Will this happen?

Answer: 
Since you did not post the implementation of your event classes there might be multiple issues in your code.

1. As already mentioned your access to m\_bPaused might be an issue.
2. Thread B calls `Set()` right before `Wait(0)`. Are you sure that thread A will get notified or does Thread B consume the notification.
3. In nearly all multi thread classes there is the problem of a spurious wake. It seems that your Thread B is not protected against this.

So it is really hard to tell if this code will be deadlock free or not.
Can't say for sure. `m_bPaused` is possibly a non-atomic variable which means the concurrent access is Undefined Behavior.