title: How to join a std::thread from itself (in C++11)
body: <p>I have a <code>std::thread</code> waiting and reading from a socket. And there is a pointer to this <code>thread</code> stored somewhere. But when something bad happens and the <code>thread</code> ends, I want it to call something that results in a function that will join this thread and then delete the pointer referring to it. (I have access to that pointer from within the thread)</p>
  
  <p>I could do that in another thread but then that new thread becomes the problem.</p>