title: Print passed argument to pthread_create
body: <p>I want to print the passed to <code>create_thread</code> argument. I create an array with 10 <code>int</code>'s to simulate the number of each thread - </p>
  
  <pre><code>void* thr_func(void *arg){
  
  printf("\nTHREAD ID %d", *(int*)arg);
  return 0;
  
  }
  
  
  int main(){
  int arr[10]={0,1,2,3,4,5,6,7,8,9};
  
  pthread_t thread_id;
  for(int i=0;i&lt;10;i++){
  
  pthread_create(&amp;thread_id, NULL, &amp;thr_func,&amp;arr[i]);
  }
  return 0;
  
  }
  </code></pre>
  
  <p>Here is the output from two runs
  1: </p>
  
  <pre><code>THREAD ID 1
  THREAD ID 5
  THREAD ID 6
  THREAD ID 2
  THREAD ID 3
  THREAD ID 4
  TTHREAD ID 0
  THREAD ID 3
  </code></pre>
  
  <p>2:</p>
  
  <pre><code>THREAD ID 1
  THREAD ID 2
  THREAD ID 5
  THREAD ID 6
  THREAD ID 3
  THREAD ID 7
  THREAD ID 4
  THREAD ID 8
  THREAD ID 8
  </code></pre>
  
  <p>I know I can't rely on consecutive numbers, but why does it print some of them twice ? </p>