zoukankan      html  css  js  c++  java
  • Linux多线程编程

    线程和进程的区别是:

      进程是拷贝主进程的数据段和代码段的。

      线程是和主进程公用一份数据段和代码段的。

         线程一旦创建,就从指定的入口函数开始执行。

    相关头文件:

      #include <pthread.h>

    操作函数:

      创建线程: int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine) (void *), void *arg);

      参数: thread:  新创建的线程ID

          attr:  待创建线程的属性

          start_routine:  待创建线程的入口函数 

          arg:  线程入口的参数(可以为空)

      返回值: 成功:0    失败:错误编码

      等待线程结束: int pthread_join(pthread_t thread, void **retval);

      参数: thread:  要等待线程结束的ID

          retval:  保存线程退出时的状态。可以不保存(NULL)

      返回值: 成功:0    失败:错误编码

      退出线程: void pthread_exit(void *retval);

      参数:   retval:  保存线程退出时的状态。可以不保存(NULL)

      返回值: 成功:0    失败:错误编码

    sd

  • 相关阅读:
    Go:获取命令行参数
    Go:文件操作
    Go:类型断言
    GO:interface
    Go:面向"对象"
    Go:工厂模式
    layui中流加载layui.flow
    js显示当前时间
    layui中的分页laypage
    layui中的多图上传
  • 原文地址:https://www.cnblogs.com/ynxf/p/6105970.html
Copyright © 2011-2022 走看看