title: C++11 multithreading with class member function
body: <p>I want to use multithreading in C++11 to call a class member function in its own thread. I have been able to get this to work with a global function:</p>
  
  <pre><code>#include &lt;thread&gt;
  #include &lt;iostream&gt;
  
  void Alpha(int x)
  {
      while (true)
      {
          std::cout &lt;&lt; x &lt;&lt; std::endl;
      }
  }
  
  int main()
  {
      std::thread alpha_thread(Alpha, 5);
      alpha_thread.join();
  
      return 0;
  }
  </code></pre>
  
  <p>However, I cannot get it to compile with a class member function:</p>
  
  <pre><code>#include &lt;thread&gt;
  #include &lt;iostream&gt;
  
  class Beta
  {
  public:
      void Gamma(int y)
      {
          while (true)
          {
              std::cout &lt;&lt; y &lt;&lt; std::endl;
          }
      }
  };
  
  int main()
  {
      Beta my_beta;
      std::thread gamma_thread(my_beta.Gamma, 5);
      gamma_thread.join();
  
      return 0;
  }
  </code></pre>
  
  <p>The compile error is:</p>
  
  <pre><code>no matching function for call to 'std::thread::thread(&lt;unresolved overloaded function type&gt;)'
   std::thread gamma_thread(my_beta.Gamma, 5);
                                      ^
  </code></pre>
  
  <p>What am I doing wrong?</p>