pthread_join(pth, NULL);
来源:互联网 发布:为什么网络ip地址冲突 编辑:程序博客网 时间:2024/06/18 18:04
#include <pthread.h>
#include <unistd.h>
#include <stdio.h>
void *thread(void *str)
{
int i;
for (i = 0; i < 10; ++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, (void *)(i));//此处 下面2个 没有阻塞,则结果 进程直接往下运行,上面thread线程直接没有运行 就直接退出了
//pthread_join(pth, NULL);
printf("123\n");
for (i = 0; i < 10; ++i)
{
//sleep(1);
printf( "This in the main : %d\n" , i );
}
return 0;
}
#include <unistd.h>
#include <stdio.h>
void *thread(void *str)
{
int i;
for (i = 0; i < 10; ++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, (void *)(i));//此处 下面2个 没有阻塞,则结果 进程直接往下运行,上面thread线程直接没有运行 就直接退出了
//pthread_join(pth, NULL);
printf("123\n");
for (i = 0; i < 10; ++i)
{
//sleep(1);
printf( "This in the main : %d\n" , i );
}
return 0;
}
- pthread_join(pth, NULL);
- pthread_join
- pthread_join
- pthread_join
- pthread_join
- pthread_join
- pthread_join
- pthread_join()
- pthread_join
- pthread_join
- pthread_join
- pthread_join函数
- pthread_join 详解
- pthread_join/pthread_exit
- pthread_join手册
- pthread_join/pthread_exit
- pthread_join()函数
- pthread_join作用
- java与C#的简单比较
- response.sendRedirect("")和request.getRequestDispatcher("").forward(req,resp);
- Git详解之二:Git基础
- 九九乘法表的各种输出形式(c++)
- 黑马程序员-GUI编程总结
- pthread_join(pth, NULL);
- Monads in Scala Part Two: More Maybes
- 应用程序端口分类
- ubuntu添加开机启动项
- 叙利亚局势
- 行人检测(Pedestrian Detection)资源
- K&R C vs ANSI C (error C2143: syntax error : missing ';' before 'type' in Visual Studio 2008)
- C语言学习笔记(一)
- broadcast