我先给你看一下函数:
for (i=0; i<3;i=i+2){
pthread_create(&thread1, NULL, &randtrack, (void *)&rnum_array[i]);
pthread_create(&thread2, NULL, &randtrack, (void *)&rnum_array[i+1]);
pthread_join(thread1, NULL);
pthread_join(thread2, NULL);
}
print final result here;
我的理解是创建两个线程后,父线程会在join(thread1)处阻塞,线程2实际上比thread1早回来的是什么?怎样才能让更长的线程永远留在后面?
谢谢