title: Best practice to destroy class object from the thread started from this's objecs's method
body: <p>So, so the title sounds mad, I think code will provide better understanding for my question</p>
  
  <pre><code>class Class
  {
  public:
      static void* thread_func(void *thisObject)
      {
          // do some work
          delete thisObject; // cleanup
  
      }
  
      start_thread()
      {
          auto worker = std::thread(thread_func, this);
          worker.detach();
      }
  }; 
  </code></pre>
  
  <p>How to use this class</p>
  
  <pre><code>Class *p = new Class;
  
  p-&gt;start_thread(); // start some work in parralel and return from function
  </code></pre>
  
  <p>So, I need to delete allocated object after thread_func is done. What is best way to implement such behaviour? Deleting thisObject from thread function as shown in the code sample works well, but looks as bad practice.</p>