2
所以我有下面的代码,其中一些遗漏了,所以它更容易理解。pthread_join跳过第一个线程
for (unsigned int t = 0; t < NUM_THREADS; t++)
{
if (pthread_create(&threads[t], NULL, thread_run, (void*) &threadData) != 0)
{
perror("pthread_create");
}//end if
}
for (unsigned int z = 0; z < NUM_THREADS; z++)
{
if (pthread_join(threads[z], NULL) != 0)
{
perror("pthread_join");
}
}
我的问题是连接函数,它跳过我创建的第一个线程,并继续。我现在的解决方案是增加一个额外的线程,而不是让第一个人做任何工作。
任何想法,为什么会发生这种情况?
Opps;那不是假设在那里,那是在我的问题的解决方案中使用,我现在将更新代码。 – Pieces 2011-02-17 23:33:46