title: Call join child pthread in main function
body: <p>I have the test code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;pthread.h&gt;
  
  pthread_t th_worker, th_worker2;
  
  
  
  void * worker2(void *data) {
      for(int i = 0; i&lt; 1000000; i++){
              printf("thread for worker2----%d\n", i);
              usleep(500);
      }
  }
  void * worker(void *data){
      pthread_create(&amp;th_worker2, NULL, worker2, data);
  
      for(int i = 0; i&lt; 100; i++){
              printf("thread for worker-----%d\n", i);
              usleep(500);
      }
  }
  void join(pthread_t _th){
      pthread_join(_th, NULL);
  }
  </code></pre>
  
  <p>In main() function, If I call join(the_worker2):</p>
  
  <pre><code>int main() {
      char* str = "hello thread";
  
      pthread_create(&amp;th_worker, NULL, worker, (void*) str);
      /* problem in here */
      join(th_worker2);
  
      return 1;
  }
  </code></pre>
  
  <p>--> Segment Fault error </p>
  
  <p>Else, i call:</p>
  
  <pre><code>join(the_worker);
  join(th_worker2);
  </code></pre>
  
  <p>---> OK</p>
  
  <p>Why have segment fault error in above case?
  Thanks for help !!!</p>