zoukankan      html  css  js  c++  java
  • Linux多线程编程笔记(2) pthread库提供的基本操作。

    1.线程的创建(pthread_create)

    2.线程的退出(pthread_exit)

    3.等待线程结束(pthread_join)

    4.线程的分离(pthread_detach)

    5.获取当前线程(pthread_self)

    1.线程的创建:

      函数的原型如下:

     int pthread_create(pthread_t* thread,

                                   pthread_attr_t* attr,

                                   void* (*start_routine) (void*),

                                   void * arg);

     第一个参数为pthread_t类型的指针,用来存放创建成功后所创建的进程的标志,一般需要提前声明。

     第二个参数表明被创建线程拥有的属性。

     第三个参数是一个函数指针,指向线程的实现函数。其实现函数的返回类型为void*,传递的参数类型是void*。

     第四个参数arg是void * 类型的 ,用来传递线程实现函数的参数。

     如果pthread_create()函数调用成功,返回值0。如果发生错误,返回非负的错误代码。

    待续...

  • 相关阅读:
    六、springboot集成Swagger2
    五、springboot单元测试
    四、Springboot Debug调试
    三、springboot热部署
    二、springboot配置
    一、springboot入门
    SpringBoot整合RabbitMQ
    消息总线
    分布式配置
    路由网关---zuul
  • 原文地址:https://www.cnblogs.com/zihuyishi/p/2991391.html
Copyright © 2011-2022 走看看