title: Wait for thread to end (C++)
body: <p>I'm asking your help to better understand some things about C++ threads.
  I'm using codeblocks with GNU GCC compiler, so since there is no pthread.h (AFAIK) I'm using process.h and _beginthread.
  I'd like that the function that the thread will execute be reusable. There is a while(!finished) statement in that function, so I can set finished to true when I'd like that the thread ends.
  Everytime that I click a button, I'd like that the finished variable will be set to true, then I'd like to wait till the thread die, and then I'd like to start another thread using the same function. 
  So, how can I wait the end of the first thread ?
  Sorry if this is a bit complicated to understand, but I can't explain it better.</p>
  
  <p>I hope that somebody can help me, I'm new to threads world, and I really need you help.
  Thank you very much.</p>