I have a basic program to test pthread_create:
int main (int argc, char *argv[])
{
pthread_t threads[NUM_THREADS];
long t;
for(t=0; t<NUM_THREADS; t++){
/* TODO assignment 3.2 a) */
pthread_create(&threads[t], NULL, SomeFunction, t);
// pthread_join(threads[t], NULL);
}
printf("Completed. Exiting\n");
pthread_exit(NULL);
}
Everytime I ran it, it creates threads in a random order without considering the for loop. What is the reason for that?