title: WaitForSingleObject is not locking, Still allowing other threads to change value in C++
body: <p>I'm trying to use <code>WaitForSingleObject(fork[leftFork], Infinite);</code> to lock a variable using multiple threads but it doesn't seem to lock anything </p>
  
  <p>I set the <code>Handle fork[5]</code> and then use the code below but it doesn't seem to lock anything.</p>
  
  <pre><code>while(forks[rightFork] == 0 || forks[leftFork] == 0) Sleep(0);
  WaitForSingleObject(fork[leftFork], INFINITE);
  forks[leftFork]--;
  
  WaitForSingleObject(fork[rightFork], INFINITE);
  forks[rightFork]--; 
  </code></pre>
  
  <p>I have tried as a <code>WaitForMultipleObjects</code> as well and same result. When I create the mutex I use <code>fork[i]= CreateMutex(NULL, FALSE,NULL);</code></p>
  
  <p>I was wondering if this is only good for each thread or do they share it?</p>