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