title: pthread_join() is not working
body: <p>I'm experimenting with posix threads and just can't figure out the problem I'm facing right now.</p>
  
  <p>Blink1 and Blink2 get called in two threads, Blink1 is supposed to exit and have main join it, after that Blink2 is supposed to get  terminated by main.</p>
  
  <p>What happens is that Blink1 does its 5 time loop but Blink2 just stays infinite, the 'printf("joined\n");' in main never gets called.</p>
  
  <p>What am I missing? Once again too stupid to read the manual?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;pthread.h&gt;
  
  int i = 0;
  
  void *blink1(){
      int j;
      for ( j = 0; j &lt; 5; j++){
          //activate
          printf("blink1: i = %d ON\n", i);
          sleep(1);
          //deactivate
          printf("blink1: i = %d OFF\n", i);
          sleep(1);
      }
      pthread_exit(NULL);
  }
  
  void *blink2(){
      while (1){
          //activate
          printf("blink2: i = %d ON\n", i);
          sleep(1);
          //deactivate
          printf("blink2: i = %d OFF\n", i);
          sleep(1);
          i++;
      }
  }
  
  int main(){
      pthread_t thrd1, thrd2;
  
      //start threads
      pthread_create(&amp;thrd1, NULL, &amp;blink1, NULL);
      pthread_create(&amp;thrd1, NULL, &amp;blink2, NULL);
  
      //output pid + tid
      printf("PID: %d ; TID1: %lu ; TID2: %lu\n", getpid(), thrd1, thrd2);
  
      //wait for thread 1
      pthread_join(thrd1, NULL);
      printf("joined\n");
  
      //terminte thread 2
      pthread_kill(thrd2, 15);
  
      return 0;
  }
  </code></pre>