title: C linux pthread needs sleep to work
body: <p>I'm writing a program in c on linux using gcc.
  If I'm not using that sleep statement
  it will print "thread created" 2,3 or 4 number of times randomly. Can anyone explain me this behavior?
  //the following code is just a sample, i know is not really useful to create a thread just to print a string :) </p>
  
  <pre><code>void* makeRequest(void* arg) {
      printf("Thread created\n");
  }
  
  int main(){
     pthread_t thr[10];
     for(i=0; i&lt;3; i++){  
         pthread_create(&amp;thr[i], 0, makeRequest, &amp;i);
         sleep(1);
      }
   }
  </code></pre>
  
  <p>p.s. I included pthread.h and the compile option -pthread</p>