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