pthread_create()函数样例
来源:互联网 发布:采样率转换算法 编辑:程序博客网 时间:2024/06/06 01:46
#include <stdio.h>#include <pthread.h>#include <unistd.h>void* client_pthread(void* arg){ printf("call client_pthread()\n"); while(1) { sleep(3); printf("call client_pthread()\n"); }}void* client_pthread_two(void* date_two){ printf("call client_pthread_two()\n"); while(1) { sleep(3); printf("call client_pthread_two()\n"); }}void test_pthread_client(void){ int ret = 0; pthread_t pthread_id; pthread_t pthread_id_two; printf("call test_pthread_client()\n"); ret = pthread_create(&pthread_id, NULL, client_pthread, NULL); if(0 != ret) { printf("create pthread false\n"); return; } ret = pthread_create(&pthread_id_two, NULL, client_pthread_two, NULL); if(0 != ret) { printf("create pthread false\n"); return; } pthread_join(pthread_id,NULL); //加入pthread_join后,主线程会一直等待直到等待的线程结束自己才结束,使创建的线程有机会执行。 pthread_join(pthread_id_two,NULL); }int main(){ printf("call main()\n"); test_pthread_client(); return 0;}
阅读全文
0 0
- pthread_create()函数样例
- pthread_create 函数
- pthread_create()函数
- pthread_create()函数
- pthread_create函数
- pthread_create函数
- pthread_create函数
- pthread_create()函数
- pthread_create函数
- pthread_create函数 pthread_self 函数
- pthread_create()函数说明
- pthread_create 函数用法
- pthread_create函数使用
- pthread_create()函数用法
- pthread_create函数详解
- linux函数之pthread_create
- pthread_create()函数用法
- linux pthread_create()函数用法
- SQL连接查询保障效率的简易原则
- Yii2 yii2-imagine的使用
- LeetCode题解–200. Number of Islands
- 自定义框架之连接池和事务管理
- JAVA中获得今天是星期几
- pthread_create()函数样例
- usaco5.4.1 Canada Tour
- TableViewCell定制
- Kotlin学习博客和文章
- struts开发简易版(只用struts2)
- Python 1行代码实现文本分类(实战笔记),含代码详细说明及运行结果
- 回调方法介绍之中国好室友篇(Java示例)
- Android Studio使用gradle导出jar包并混淆代码代码记录二
- JAVA,假重写,方法假重写,继承父类时的静态方法假重写,静态方法假重写