单选题
1分
有如下C语言程序void * th_f(void * arg){printf("Hello World");}int main(void){...
有如下C语言程序
void * th_f(void * arg)
{
printf("Hello World");
}
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);
}
针对上述程序,下列叙述中哪一个是正确的?
void * th_f(void * arg)
{
printf("Hello World");
}
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);
}
针对上述程序,下列叙述中哪一个是正确的?
参考答案: D
参考解析: 【解析】分析线程th_f的代码可知:代码只有一个printf()函数调用语句,没出错的指令,排除A,没有等待其他线程的指令,排除B,没有调用阻塞原语的指令,排除C,只有一个printf函数调用语句,所以线程会执行完指令后退出。所以选D选项。