linux 线程函数、结构体
来源:互联网 发布:软件开发流程管理制度 编辑:程序博客网 时间:2024/05/01 00:44
001:
typedef unsigned long intpthread_t;
用途:pthread_t用于声明线程ID。
sizeof (pthread_t) =8;
002:
pthread_join(...)
头文件 : #include <pthread.h>
函数定义: int pthread_join(pthread_t thread, void **retval);
pthread_join()函数,以阻塞的方式等待thread指定的线程结束。当函数返回时,被等待线程的资源被收回。如果进程已经结束,那么该函数会立即返回。并且thread指定的线程必须是joinable的。
thread: 线程标识符,即线程ID,标识唯一线程。
retval: 用户定义的指针,用来存储被等待线程的返回值。
返回值 : 0代表成功。 失败,返回的则是错误号。
003:
pthread_create(...)
#include <pthread.h>
int pthread_create(pthread_t *thread, const pthread_attr_t *attr,void *(*start_routine) (void *), void *arg);
若线程创建成功,则返回0。若线程创建失败,则返回出错编号,并且*thread中的内容是未定义的。
第一个参数为指向线程标识符的指针。
第二个参数用来设置线程属性。
第三个参数是线程运行函数的起始地址。
最后一个参数是运行函数的参数。
因为pthread并非Linux系统的默认库,而是POSIX线程库。在Linux中将其作为一个库来使用,因此加上 -lpthread(或-pthread)以显式链接该库。函数在执行错误时的错误信息将作为返回值返回,并不修改系统全局变量errno,当然也无法使用perror()打印错误信息。
- linux 线程函数、结构体
- 线程函数传递结构体
- linux函数、结构体研究
- 时间结构体/函数-linux
- 线程临界区相关结构体和函数
- 给线程处理函数传结构体参数
- linux-时间相关结构体和函数
- linux-时间相关结构体和函数
- linux-时间相关结构体和函数
- Linux sysinfo函数、结构体使用
- Linux sysinfo函数、结构体使用
- linux线程-函数
- linux 线程函数大全
- LINUX 线程函数大全
- LINUX 线程函数大全
- linux 线程常用函数
- linux线程函数大全
- linux线程操作函数
- when i change PCB footprint ,all become green warn!
- ACE相关学习文章
- 湖北原副省长郭有明被开党籍:收受贿赂道德败坏
- linux 多线程 遇到的问题
- dumpbin导出OBJ的汇编文本
- linux 线程函数、结构体
- 存个KMP模板
- Swap Nodes in Pairs
- Web开发常见的几个漏洞解决方法
- 一代宗师观感
- 加密与解密 11
- 并查集 BZOJ 1015 1015: [JSOI2008]星球大战starwar
- java生成word,html文件并将内容保存至数据库 (http://blog.163.com/whs3727@126/blog/static/729915772007325112014115/)
- 在matlab中生成m序列