title: pthread creation not working properly
body: <p>i have this piece of code:</p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;pthread.h&gt;
  #include &lt;time.h&gt;
  
  int number;
  pthread_mutex_t  *mutex;
  pthread_t *threads;
  
  void *PrintHello(void *threadid)
  {
      long tid;
      tid = (long)threadid;
      printf("Hello World! It's me, thread #%ld!\n", tid);
      time_t rawtime;
      struct tm * time_start;
      time ( &amp;rawtime );
      time_start = localtime ( &amp;rawtime );
      printf ( "The number %ld thread is created at time %s  \n",tid, asctime     (time_start));
      pthread_exit(NULL);
  }
  
  int main(int argc, char *argv[])
  {
      int i,rc;
  
      printf("give threads");
      scanf("%d",&amp;number);
      mutex = calloc( number, sizeof(*mutex));
      threads = calloc(number, sizeof(*threads));
  
      for (i = 0; i &lt; number;i++) {
          pthread_mutex_init( &amp;mutex[i],NULL);
      }
  
      for(i=0; i&lt;number; i++){
          printf("In main: creating thread %d\n", i);
          rc = pthread_create(&amp;threads[i], NULL, PrintHello, (void *)i);
          if (rc){
              printf("ERROR; return code from pthread_create() is %d\n", rc);
              exit(-1);
          }
      }
  
      return 0;
  }
  </code></pre>
  
  <p>The purpose of this code is to ask the user to give the number of the threads that it is going to create and after the creation of the threads,the thread itself will print 2 messages saying the number of the thread and the time that it was created.</p>
  
  <p>The problem is that inside the main the message <code>"In main: creating thread"</code> is showing up but the message inside the threads sometimes does not.</p>
  
  <p>For example, it would create 3 threads and only 1 thread will show up its message and that thread also will not show up the time that was created. I dont know if there is something wrong with the code.</p>