I've the following code in my programm:
for (i = 0; i < numthrs; i++)
{
if (0 != pthread_create(&thrs[i], NULL, thr_main,
&args[i]))
{
/* handle error */
}
printf("thread %d created.\n", i);
if (0 != pthread_join(thrs[i], &thread_status))
{
/* handle error */
}
printf("joined thread %d\n", i);
}
But I've noticed that the threads don't run simultaneously, the second thread starts its execution only after the first thread has completed its execution. I'm new to pthread programming. Can someone tell me what's the proper way to start some threads simultaneously?
Aucun commentaire:
Enregistrer un commentaire