pthread 等待
来源:互联网 发布:英美澳加新 知乎 编辑:程序博客网 时间:2024/06/05 09:08
pthread 等待
#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <pthread.h>#include <errno.h>/*struct number{int number;char *string;};*///;不可少void *create(void *arg){int i;for(i=0;i<=10;i++){sleep(2);printf("In the process %d\n",i);}return (void*)0;}int main(int argc,char *argv[]){pthread_t pthid;int i;int errno;errno=pthread_create(&pthid,NULL,create,NULL);if(errno){printf("create pthread failure!\n");exit(EXIT_FAILURE);}pthread_join(pthid,NULL);printf("thread exit!\n");for(i=0;i<10;i++){printf("int the process %d\n",i);}return 0;}
[root@localhost sourcetemp]# ./pthread_block
In the process 0
In the process 1
In the process 2
In the process 3
In the process 4
In the process 5
In the process 6
In the process 7
In the process 8
In the process 9
In the process 10
thread exit!
int the process 0
int the process 1
int the process 2
int the process 3
int the process 4
int the process 5
int the process 6
int the process 7
int the process 8
int the process 9
遇到的问题:
1.pthread_join是两个参数;
- pthread 等待
- Pthread
- pthread
- pthread
- PThread
- pthread
- pthread
- pthread
- pthread
- pthread
- pthread
- pthread
- pthread
- pthread
- pthread
- Pthread
- pthread
- pthread
- 黑马程序员-Ado.net学习之参数化查询(防止sql注入)
- com技术内幕--读书笔记(6)
- LINUX基本命令
- struts2学习笔记
- 使用quartz2D绘制阴影的代码
- pthread 等待
- 六之续、由KMP算法谈到BM算法
- LINUX查找命令、替换、管道符号
- 我的2011卖身记
- linux下gdb单步调试(中)(转摘)
- (android developers)intent
- 两种跳转方式分别是什么?有什么区别
- linux下gdb单步调试(下)(转摘)
- B+树与2-3-4树