title: OpenMP: Why are these omp parallel sections not executed with multiple threads?
body: <p>I am trying to parallelize some code, but I am running into (presumably dumb) problems. The example code below returns "12", although I'd expect "21". </p>
  
  <p>omp_get_max_threads() returns 8, omp_get_num_threads() returns 1 and omp_get_thread_num()  returns 0 when I call them anywhere in this block. I guess I can conclude that it just gets executed by the master thread sequentially.</p>
  
  <pre><code>#include &lt;omp.h&gt;
  #include &lt;iostream&gt;
  #include &lt;Windows.h&gt;
  
  using namespace std;
  
  int main() {
      #pragma omp parallel sections num_threads(2) 
      {
          #pragma omp section 
              { Sleep(200);
                cout &lt;&lt; "1"; }
          #pragma omp section 
              { cout &lt;&lt; "2"; }
      }
  }
  </code></pre>
  
  <p>What am I doing wrong? How can I force parallel processing of these sections? </p>
  
  <p>For context: I am streaming data from two USB 3.0 cameras and calling the image from each sequentially is so slow that I am losing frames. I would like to basically set one thread aside for each camera to constantly demand its image.</p>
  
  <p><a href="https://stackoverflow.com/questions/13209686/openmpwhy-am-i-not-getting-different-thread-ids-when-i-uses-pragma-omp-paral">This</a> question has a similar title but didn't help. I'm using Visual Studio 2010.</p>