单选题
1分
对于如下C语言程序void *th_f(void * arg){printf("Hello World");pthread_join(2);}int ...
对于如下C语言程序
void *th_f(void * arg)
{
printf("Hello World");
pthread_join(2);
}
int main(void)
{
pthread_t tid;
int st;
st = pthread_create(&tid, NULL, th_f, NULL);
if(st==0)
printf("Oops, I can not createthread\n");
exit(NULL);
}
在上述程序中,pthread_join函数的意义是
void *th_f(void * arg)
{
printf("Hello World");
pthread_join(2);
}
int main(void)
{
pthread_t tid;
int st;
st = pthread_create(&tid, NULL, th_f, NULL);
if(st==0)
printf("Oops, I can not createthread\n");
exit(NULL);
}
在上述程序中,pthread_join函数的意义是
参考答案: B
参考解析: Pthread线程包中,pthread_join函数是等待一个特定的线程退出,题意中,main函数中创建一个新线程,新线程的创建后,从入口函数th_f开始执行,输出Hello World后,调用pthread_join等待线程ID为2的线程退出,答案为B。