多线程编程
来源:互联网 发布:开淘宝店好做吗 编辑:程序博客网 时间:2024/06/16 07:39
多线程编程/* 注意: 在编译pthread时, 需要加链接库: -lpthread*/{#include <pthread.h>/* 创建线程 */int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*routine)(void *),void *arg);thread : 创建线程attr: 指定线程的属性,null表示使用缺省属性routine:线程执行的函数arg:传递给线程执行的函数的参数返回值:成功:返回0,出错:返回错误号/* 等待线程 */int pthread_join(pthread_t thread, void **value_ptr);thread: 要等待的线程value_ptr:指向线程返回的参数返回值: 成功:返回0 出错:返回错误号/* 线程退出 */void pthread_exit(void *value_ptr);value_ptr:线程退出时返回的值/* 取消线程 */int pthread_cancel(pthread_t thread);thread:要取消的线程返回值 成功:返回0 出错:返回错误号}return exit pthread_exit的区别{return : 返回函数exit : 退出线程pthread_exit: 退出线程(接收返回值)}
阅读全文
0 0
- 多线程编程
- 多线程编程
- 多线程编程
- 多线程编程
- 多线程编程
- 多线程编程
- 多线程编程
- 多线程编程
- 多线程编程
- 多线程编程
- 多线程编程
- 多线程编程
- 多线程编程
- 多线程编程
- 多线程编程
- 多线程编程
- 多线程编程
- 多线程编程
- 【BigHereo 13】-----Constant Grow
- linux socket编程的异常原因及处理
- 编辑距离
- ios开发之路(一)
- Git学习笔记四:Git远程服务器
- 多线程编程
- Mac vi编辑器
- ccf ISBN号码
- [LeetCode] 169. Majority Element
- 1047. 编程团体赛
- 《Python语言及其应用》读书笔记(4)之第5章Python盒子:模块、包和程序(关键词:模块/包/程序)
- 接口自动化测试-Fiddler抓包工具常用操作
- Divide and Conquer -- Leetcode problem215: Kth Largest Element in an Array
- Jdk1.8覆盖了原来1.7的版本,如何还原到1.7版本?