title: pthread_join - multiple threads waiting
body: <p>Using POSIX threads &amp; C++, I have an "Insert operation" which can only be done safely one at a time.</p>
  
  <p>If I have multiple threads waiting to insert using pthread_join then spawning a new thread 
  when it finishes. Will they all receive the "thread complete" signal at once and spawn multiple inserts or is it safe to assume that the thread that receives the "thread complete" signal first will spawn a new thread blocking the others from creating new threads.</p>
  
  <pre><code>/* --- GLOBAL --- */
  pthread_t insertThread;
  
  
  
  /* --- DIFFERENT THREADS --- */
  // Wait for Current insert to finish
  pthread_join(insertThread, NULL); 
  
  // Done start a new one
  pthread_create(&amp;insertThread, NULL, Insert, Data);
  </code></pre>
  
  <hr>
  
  <p>Thank you for the replies</p>
  
  <p>The program is basically a huge hash table which takes requests from clients through Sockets.</p>
  
  <p>Each new client connection spawns a new thread from which it can then perform multiple operations, specifically lookups or inserts. lookups can be conducted in parallel. But inserts need to be "re-combined" into a single thread. You could say that lookup operations could be done without spawning a new thread for the client, however they can take a while causing the server to lock, dropping new requests. The design tries to minimize system calls and thread creation as much as possible. </p>
  
  <p>But now that i know it's not safe the way i first thought I should be able to cobble something together</p>
  
  <p>Thanks</p>