title: Thread-safety of writing a std::vector vs plain array
body: <p>I've read <a href="https://stackoverflow.com/questions/1362110/is-the-c-stdset-thread-safe">on Stackoverflow</a> that <strong>none of the STL containers are thread-safe for writing</strong>. But what does that mean in practice? Does it mean I should store writable data in plain arrays?</p>
  <p>I expect concurrent calls to <code>std::vector::push_back(element)</code> could lead to inconsistent data structures becaue it might entail resizing the vector. But what about a case like this, where resizing is not involved:</p>
  <ol>
  <li>using an array:</li>
  </ol>
  <pre class="lang-cpp prettyprint-override"><code>int data[n];
  // initialize values here...
  
  #pragma omp parallel for
  for (int i = 0; i &lt; n; ++i) {
      data[i] += func(i);
  }
  </code></pre>
  <ol start="2">
  <li>using a `std::vector``:</li>
  </ol>
  <pre class="lang-cpp prettyprint-override"><code>std::vector&lt;int&gt; data;
  data.resize(n);
  // initialize values here...
      
  #pragma omp parallel for
  for (int i = 0; i &lt; n; ++i) {
      data[i] += func(i);
  }
  </code></pre>
  <p>Is the first implementation really better than the second one a) in terms of thread-safety and b) in terms of performance? I would prefer to use a std::vector, since I am less comfortable with C-style arrays.</p>
  <p>EDIT: I removed a <code>#pragma omp atomic update</code> protecting the write.</p>