title: How to use "#pragma omp parallel for" correctly to get profit to fill the array Qvector
body: <p>I'm learning c++ and trying to make my own calculator with charting. In this part, when I try to fill an array with coordinates. I want to make it faster using multithreading. But when I did so, the code began to work much worse, slower. How can I solve the problem what am I doing wrong? By the way, it doesn't work at all without &quot;#pragma omp critical&quot;</p>
  <pre><code>    omp_set_num_threads(2);
      #pragma omp parallel for
      for (current = start; current &lt; finish; current ++) {
          Calc b(a.get_string());
          double y_value = b.parsing((double)current/1000);
          #pragma omp critical
          {
              if (y_value &gt; yL || y_value &lt; yR) {
                  x-&gt;push_back((double)current/1000);
                  y-&gt;push_back(y_value);
              }
          }
  </code></pre>
  <p>x and y this is QVector.
  Please try to express yourself as simply as possible because I'm just learning. Thank you all very much!</p>