有如下C语言程序。 void * th_f(void * arg) { printf("Ni Hao"); pthread_yiled(0); } int main(void) { pthread_t tid; int at

admin2022-06-21  24

问题 有如下C语言程序。
  void * th_f(void * arg)
  { printf("Ni Hao");
  pthread_yiled(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);}
  针对以上程序,下列叙述中正确的是(          )。

选项 A、线程th_f运行后主动退出
B、线程th_f运行后等待一个特定的线程退出
C、线程th_f运行后主动释放CPU给其他线程
D、线程th_f运行后成为僵尸

答案C

解析 pthread_create(&tid,NULL,th_f,NULL):创建线程后,运行该线程,th_f线程中调用了pthread_yield(0)。线程th_f运行后等待该线程退出后挂起自己,将CPU让给其他线程。因此,本题答案选择C选项。
转载请注明原文地址:https://kaotiyun.com/show/rXyZ777K
0

相关试题推荐
最新回复(0)