title: How to add threads during run of program in C?
body: <p>I am adding threads as user wants. It means I stdin and if he wants new thread I create it. User give specific name to thread so I can not create it sooner than he wants.
  Part of my code:</p>
  <pre><code>while(read != EOF) {
      if(user_wants_new_thread) {
  
          worker_t *data = malloc(sizeof(worker_t));
  
          data-&gt;name  = malloc((strlen(arg1) + 1) * sizeof(char));
          strcpy(data-&gt;name, arg1);
  
          pthread_create(&amp;thread, NULL, worker, (void *) data);
          pthread_join(thread, NULL);
  
          pthread_mutex_lock(&amp;mutex);
  
          pthread_cond_signal(&amp;cond);
  
          pthread_mutex_unlock(&amp;mutex);
  
      }
  }
  </code></pre>
  <p>Thread should start to work without waiting. Now it waits for finishing of worker function.
  Thank you for help :)</p>