title: In C++ multithreading applications, should I pass lambda or function with parameters?
body: <p>I have just started learning about multithreading in C++...
  is there a difference between <code>t1</code> and <code>t2</code>?</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;thread&gt;
  #include &lt;mutex&gt;
  
  std::mutex mutexCout;
  
  //prints the value of x, and then increments it
  //param: int value to display and increment
  void foo (int&amp; x)
  {
      std::lock_guard&lt;std::mutex&gt; guard_(mutexCout);
      std::cout &lt;&lt; "x is " &lt;&lt; x &lt;&lt; "\n";
      ++x;
  }
  
  //testing different ways to call a function with reference
  int main() 
  {
      int x = 5;
      //is t1 different from t2???
      std::thread t1 ([&amp;] {foo(x)};
      std::thread t2 (foo, std::ref(x));
      {
          std::lock_guard&lt;std::mutex&gt; guard_(mutexCout);
          std::cout &lt;&lt; "x is " &lt;&lt; x &lt;&lt; "\n";
      }
  
      //added after posting the question
      t1.join();
      t2.join();
  
      return 0;
  }
  </code></pre>