<delect id="sj01t"></delect>
  1. <em id="sj01t"><label id="sj01t"></label></em>
  2. <div id="sj01t"></div>
    1. <em id="sj01t"></em>

            <div id="sj01t"></div>
            C語言

            c語言線程終止練習示例

            時間:2025-02-09 03:20:21 C語言 我要投稿
            • 相關推薦

            c語言線程終止練習示例

              c語言線程

              代碼如下:

              #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語言線程終止練習示例】相關文章:

            C語言基本語法示例08-15

            C語言練習02-14

            C語言作業練習03-26

            C語言練習試題07-01

            C語言的基礎練習05-06

            c語言實現多線程動畫程序范例05-22

            C語言計算日期差的方法示例03-30

            C語言socket編程開發應用示例02-25

            利用Java終止線程的方法04-05

            <delect id="sj01t"></delect>
            1. <em id="sj01t"><label id="sj01t"></label></em>
            2. <div id="sj01t"></div>
              1. <em id="sj01t"></em>

                      <div id="sj01t"></div>
                      黄色视频在线观看