对于如下C语言程序 void*th_f (void*arg) { pfintf(“Hello World”); pthread_exit(0); } int main(void) { pthread_t ti

admin2021-03-19  22

问题 对于如下C语言程序
  void*th_f (void*arg)
  {
  pfintf(“Hello World”);
  pthread_exit(0);
    }
    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_create函数表示(    )。

选项 A、创建线程,线程名为th_f
B、创建线程,线程名为tid
C、创建线程,线程名为st
D、创建线程,线程名为NULL

答案A

解析 pthread-create函数的作用是创建线程,包括有4个参数:第一个参数为指向线程标识符的指针;第2个参数用来设置线程属性;第3个参数是线程入口函数的起始地址。最后一个参数是入口函数的参数。一般以线程运行函数名来命名线程名,但线程标识信息放在tid里。故本题答案选择A选项。
转载请注明原文地址:https://kaotiyun.com/show/CK8Z777K
0

最新回复(0)