title: How to safely delete a thread pointer in a destructor?
body: <p>Say, I have a C++ class including a thread pointer as a member variable. The thread keeps running until the program exits. <strong>If I delete the pointer in the destructor, it seems that the thread has not yet finished at that moment?</strong> What is the best practice to manage this or any tricks?</p>
  
  <p>Sample code:</p>
  
  <pre><code>class Car {
  public:
      Car();
      ~Car();
  private:
      boost::thread *m_runningThreadPtr;
  };
  
  
  Car::Car() {
      m_runningThreadPtr = new boost::thread();
  }
  
  Car::~Car() {
      delete m_runningThreadPtr;    // The thread should be still running now. 
                                    // Problematic if it was deleted here?
  }
  </code></pre>