title: void operator()() understanding
body: <p>I am learning how to use thread in boost library, during my search I found the code below:</p>
  
  <pre><code>struct count
  {
      count(int id) : id(id) {}
  
      void operator()()
      {
           for (int i = 0; i &lt; 10; ++i)
           {
               boost::mutex::scoped_lock
               lock(io_mutex);
               std::cout &lt;&lt; id &lt;&lt; ": " &lt;&lt; i &lt;&lt; std::endl;
           }
      }
      int id;
  };
  
  int main(int argc, char* argv[])
  {
      boost::thread thrd1(count(1));
      boost::thread thrd2(count(2));
  
      thrd1.join();
      thrd2.join();
      return 0;
  }
  </code></pre>
  
  <p>This program works fine, but my question is, what is the behaviour of the <code>void 
  operator()()</code> function? Because there are two threads and each one initializes the count with different values. It's two main <code>count</code> variables are created seperately, so their <code>void operator()()</code> should be different for each variable. But it seems that <code>void operator()()</code> is the same for both threads. One more thing in this code <code>void operator()()</code> is not being called from anywhere, so how it is running?</p>
  
  <p>Can someone please explain me what is going on inside this function?</p>
  
  <pre><code>void operator()() 
  </code></pre>