title: How can I run 4 threads each on a different core (parallelism)?
body: <p>I want to run in parallel (<strong>not concurrently</strong>)<sup>1</sup> four threads doing completely independent things. I'm new to parallelism and I have a couple of questions. The reason why I want to do this is because <strong>performance is really important</strong> for me. I'm working on a 4-core Windows machine and I'm using C++ in Visual Studio Community 2015.</p>
  <p>Should I try to schedule the threads myself, so that each one runs on a different core or should I leave the OS Scheduler to do that? In my opinion I think it would be faster if I force it to run each thread on a different core. How can I do that?</p>
  <p>This is what I have tried so far:</p>
  <pre><code>#include &lt;thread&gt;
  void t1(){//do something}
  void t2(){//do something}
  void t3(){//do something}
  void t4(){//do something}
  
  int main(){
     std::thread thread1(t1);
     std::thread thread2(t2);
     std::thread thread3(t3);
     std::thread thread4(t4);
  
     t1.join();
     t2.join();
     t3.join();
     t4.join();
  }
  </code></pre>
  <p>I know that <code>join()</code> blocks the thread until it finishes but I'm not sure if it runs the threads in parallel? Is my code executing the threads <strong>concurrently or in parallel</strong>?</p>
  <hr>
  <p><sup>1</sup> <strong>Note:</strong></p>
  <p><em>Concurrency</em> is essentially when two tasks are being performed at the same time. This might mean that one is 'paused' for a short duration, while the other is being worked on.</p>
  <p><em>Parallelism</em> requires that at least two processes/tasks are actively being performed at a particular moment in time.</p>