2
如何將p_thread的id保存到數組中?如何將pthread_t id保存到數組
int i;
pthread_t t[N];
float arrayId[N];
for (i = 0; i < N; i++) {
pthread_create(&t[i], NULL, f, (void *) &i);
printf("creato il thread id=%lu\n", t[i]);
arrayId[i] = t[i];
printf("a[%d]=%f\n", i, arrayId[i]);
}
我可以打印,但我沒能救...
我得排序這個數組,然後我就必須先執行由ID訂購的所有線程
你用'save'表示什麼意思?因爲't'已經包含了每個線程ID,所以它被'保存'了,那麼爲什麼你需要另一個數組呢?即使你願意,使用float也沒有意義。 – stijn
看看這個http://stackoverflow.com/questions/1759794/how-to-print-pthread-t – benjarobin