title: c++ multithreading synchronization
body: <p>Here is a simplified version of my problem.</p>
  
  <p>There are N threads executing following 3 instructions in an infinite loop:</p>
  
  <pre><code>A -&gt; B -&gt; C -&gt; A -&gt; B -&gt; C -&gt; A -&gt; B -&gt; .......
  </code></pre>
  
  <p>I want that all threads execute instruction B concurrently i.e. execution of B by any thread should start only if all threads have reached B. So, if there is a thread that has executed B -> C -> A, it should wait here till other threads are also ready to execute B.</p>
  
  <p>If possible, please let me know a portable solution that'll work on both windows &amp; MAC.</p>