线程等待
来源:互联网 发布:电机pid控制算法 编辑:程序博客网 时间:2024/06/10 00:12
/*线程等待*/
/*thread_join.c*/
/*代码分析:进程在创建线程后各自独立运行,pthread_join系统调用会使进程阻塞等待线程的退出*/
#include<pthread.h>
#include<unistd.h>
#include<stdio.h>
void *thread(void *str)
{
int i;
for(i=0;i<3;i++)
{
sleep(2);
printf("this in the thread:%d\n",i);
}
return NULL;
}
int main()
{
pthread_t pth;
int i;
/*创建线程并执行线程执行函数*/
int ret=pthread_create(&pth,NULL,thread,NULL);
printf("The main process will be to run,but will be blocked soon\n");
/*阻塞等待进程以等待线程的退出*/
pthread_join(pth,NULL);
printf("thread was exit\n");
for(i=0;i<3;i++)
{
sleep(1);
printf("this in the main:%d\n",i);
}
return 0;
}
- 线程等待
- 线程等待
- 线程等待
- 线程等待
- 等待指定线程结束
- (三)线程--等待句柄
- 线程等待 WaitFor...
- 线程等待 WaitFor...
- WaitForSingleObject 等待线程句柄
- 等待线程结束
- 线程等待与唤醒
- 线程创建等待消除
- 等待窗口线程关闭
- 线程的等待
- 等待线程退出pthread_join
- 线程进入等待状态
- 线程的控制等待
- linux 线程等待队列
- init 进程和inittab 引导指令
- 消息队列的发送与接收.
- 开通csdn的第一篇博客
- jdbc
- 消息队列的接收
- 线程等待
- ipc/ 信号量的pv操作
- 自己写的快排
- 小贴士1
- 非亲缘进程间的共享内存与信号通信
- C++总是能让我想起什么(8)——访问基类函数
- 小贴士2
- Visual C++ 6.0调试功能 图解教程(1)--快速入门
- JAVA NIO