[真1][10][单选]对于如下 C 语言程序
void *th_pg(void *arg) { printf("Hello World"); pthread_join(2); } int main(void) { pthread_t ptid; int sta, stb; sta = pthread_create(&ptid, NULL, th_pg1, NULL); if (sta == 0) printf("Oops, I can not create thread1\n"); stb = pthread_create(&ptid, NULL, th_pg2, NULL); if (stb == 0) printf("Oops, I can not create thread2\n"); exit(NULL); }
在上述程序中,pthread_join 函数的意义是
线程th_pg1和th_pg1运行后主动退出
线程th pg1和th pg2运行后等待一个特定的线程退出
线程th pg1和th pg2运行后主动释放CPU给其他线程
线程th pg1和th pg2运行后成为僵尸线程
答案
线程th pg1和th pg2运行后等待一个特定的线程退出
解析
在 Pthread 线程包中,pthread_join 是等待一个特定的线程退出,根据题意,在 main 函数中调用 pthread_join(2, NULL,是等待线程 ID 为 2 的线程退出,故选择 B 选项。
转载请注明出处。