单选题
有如下C语言程序。
void *th_f(void *arg)
{ printf('Ni Hao');
pthread_exit(0);}
int main(void)
{ pthread_t tid;
int at;
at==pthread_create(&tid, NULL,th_f, NULL);
if(at==0)
printf('I can not create thread\n');
exit(NULL);}
在上述程序中,pthread_create函数表示______。
A、
创建线程,线程名为th_f
B、
创建线程,线程名为tid
C、
创建线程,线程名为st
D、
创建线程,线程名为NULL
【正确答案】
A
【答案解析】
pthread_create函数的作用是创建线程,包括有4个参数:第一个参数为指向线程标识符的指针;第2个参数用来设置线程属性;第3个参数是线程入口函数的起始地址。最后一个参数是入口函数的参数。一般以线程运行函数名来命名线程名,但线程标识信息放在tid里。因此,本题答案选择A选项。
提交答案
关闭