夜间福利网站,免费动漫av,一级做a爰片久久毛片免费陪,夜夜骑首页,黄色毛片视频,插插插操操操,综合av色

c語(yǔ)言線程終止練習(xí)示例

時(shí)間:2025-12-05 01:17:00 C語(yǔ)言

c語(yǔ)言線程終止練習(xí)示例

  c語(yǔ)言線程

  代碼如下:

  #include

  #include

  #include

  void *t1(void *args)

  {

  return (void *) 0;

  }

  void *t2(void *args)

  {

  printf("thread 2 param[args] = %dn", args);

  pthread_exit((void *) 3);

  }

  void *t3(void *args) {

  while(1)

  {

  printf("thread 3 is workingn");

  sleep(1);

  }

  }

  int main(int argc, char *argv[])

  {

  pthread_t thread;

  int err;

  void *status;

  printf("creating thread 1n");

  err = pthread_create(&thread, NULL, t1, NULL);

  if(err)

  {

  printf("Can not created thread 1n");

  exit(-1);

  }

  pthread_join(thread, &status);

  printf("thread 1 exit return code %dnn", status);

  printf("creating thread 2n");

  err = pthread_create(&thread, NULL, t2, (void *) 9);

  if(err)

  {

  printf("Can not created thread 2n");

  exit(-2);

  }

  pthread_join(thread, &status);

  printf("thread 2 exit return code %dnn", status);

  printf("creating thread 3n");

  err = pthread_create(&thread, NULL, t3, NULL);

  if(err)

  {

  printf("Can not created thread 3n");

  exit(-3);

  }

  sleep(10);

  pthread_cancel(thread);

  pthread_join(thread, &status);

  printf("thread 3 exit return code %dn", status);

  return 1;

  }

【c語(yǔ)言線程終止練習(xí)示例】相關(guān)文章:

C語(yǔ)言基本語(yǔ)法示例11-02

C語(yǔ)言練習(xí)02-14

C語(yǔ)言的基礎(chǔ)練習(xí)10-25

C語(yǔ)言作業(yè)練習(xí)10-02

C語(yǔ)言練習(xí)試題10-20

c語(yǔ)言實(shí)現(xiàn)多線程動(dòng)畫程序范例10-29

C語(yǔ)言socket編程開發(fā)應(yīng)用示例02-25

C語(yǔ)言計(jì)算日期差的方法示例09-17

C語(yǔ)言練習(xí)題09-11