zoukankan      html  css  js  c++  java
  • 最简单的线程

     #include<stdio.h>
     #include<pthread.h>
     
     
     void *print_thread_id(void *arg)
     {
             /* 打印当前线程的线程号*/
             printf("Current thread id is %u ", (unsigned)pthread_self());
     }
     
     int main(int argc, char *argv[])
     {
             pthread_t thread;               /*保存线程号*/
     
             /*创建一个线程  */
             pthread_create(&thread, NULL, print_thread_id, NULL);
     
             sleep(1);                         /*休眠1s*/
     
             /*打印进程号    */
             printf("Main thread id is %u ", (unsigned)pthread_self());
     
             return 0;
     }

  • 相关阅读:
    CentOS VPS
    Make 命令教程
    Nginx 学习
    字体对齐问题
    postman curl
    linux命令
    服务器
    操作系统
    nginx-1.15遇到无法加载php文件报404的问题
    thinkphp6.0框架下载与安装
  • 原文地址:https://www.cnblogs.com/zhangyabin---acm/p/3177561.html
Copyright © 2011-2022 走看看