title: How to make boost threads self-destruct? (C++)
body: <p>I have a class with some function like:</p>
  
  <pre><code>void workerFunc(int ClassVariable)  
  {  
      boost::posix_time::seconds workTime(classVariableA);  
  
      std::cout &lt;&lt; "Worker: running" &lt;&lt; std::endl;  
  
      // Pretend to do something useful...  
      boost::this_thread::sleep(workTime);  
  
  
      std::cout &lt;&lt; ClassVariable &lt;&lt; std::endl;  
      std::cout &lt;&lt; "Worker: finished" &lt;&lt; std::endl;  
  }  
  </code></pre>
  
  <p>which I want to be in threads. and some other function that I want to work like</p>
  
  <pre><code>while(1)
  {
   boost::thread workerThread(workerFunc(ClassVariableB));  
  }
  </code></pre>
  
  <p>so it will create thread each time it can. But what I need is for that thread to auto destruct itself when it is finished.  How to do such thing?</p>