title: Creating threads in a loop
body: <p>Is it bad to create threads in loop, like that?</p>
  
  <p>Thread function example:</p>
  
  <pre><code>void *thread_func(void* args)
  {
    const char *str = (const char *)args;
  
    printf("Threading %s\n", str);
    usleep(1000);
  }
  </code></pre>
  
  <p>Main loop:</p>
  
  <pre><code>pthread_t thread;
  while (1) {
      char *str = "test str";
      if (pthread_create(&amp;thread, NULL, thread_func, str)) {
              fprintf(stderr, "Failed to create thread\n");
              return -1;
      }
      usleep(3000);
    /* Thread guaranteed finished here */
    }
  </code></pre>
  
  <p>Or I must create it once and reuse in loop</p>