title: Synchronization between threads using Critical Section
body: <p>I have multiple threads, ThreadA and ThreadsB-Z. </p>
  
  <p>ThreadA is always in critical section, popping the data out of queue and sending it on socket. </p>
  
  <p>When any thread from ThreadB to ThreadZ want to enter the critical section, it wants ThreadA to leave critical section only then. It then enters the critical Section, push some data into queue and leaves critical section.</p>
  
  <p>I have two problems here:</p>
  
  <ol>
  <li>How would ThreadB-Z (whoever wants to enter the Critical Section)
  tell ThreadA to leave critical section when it wants
  to access the critical section.</li>
  <li>I tried with the idea of SetEvent or PostThreadMessage to tell
  threadA to leave the   critical Section, but I am unable to handle
  any Event or Thread Message since ThreadA is continuously popping
  data out of the queue using while(1) and there is no message loop or
  WaitforSingleObject() type thing to handle Events or Thread Messages
  :(</li>
  </ol>
  
  <p>I am like stuck in this situation. Any help/suggestion is welcome. Thanks in advance.</p>