pthread_exit
当主线程调用pthread_exit时,其余线程不退出,继续执行
当主线程调用exit/或return时,其余线程退出,整个进程都退出了。
#include <pthread.h>
#include <stdio.h>
#include<stdlib.h>
#include <unistd.h> #include <pthread.h> void* new_thread(void* arg)
{
while()
{
printf("new thread\n");
fflush(stdout);
sleep();
}
return NULL;
} int main(void)
{
pthread_t tid; int err = pthread_create(&tid, NULL, new_thread, (void *));
sleep();
printf("call pthread_exit\n");
fflush(stdout);
//pthread_exit(NULL); return ;
}
当mian中条用pthread_exit 时,new_thread 继续运行。
当main中直接return时,new_thread 停止运行,进程退出了。
pthread_exit的更多相关文章
- Linux多线程实例练习 - pthread_exit() 与 pthread_join()
Linux多线程实例练习 - pthread_exit 与 pthread_join pthread_exit():终止当前线程 void pthread_exit(void* retval); pt ...
- 多线程:pthread_exit,pthread_join,pthread_self
/*exit_join_id.c*/ #include<pthread.h> #include<stdio.h> void* eji(void* agr) { printf(& ...
- pthread_exit在main线程中的用处
在main线程中调用pthread_exit会起到只让main线程退出,但是保留进程资源,供其他由main创建的线程使用,直至所有线程都结束,但在其他线程中不会有这种效果 https://stacko ...
- 线程相关函数(1)-pthread_create(), pthread_join(), pthread_exit(), pthread_cancel() 创建取消线程
一. pthread_create() #include <pthread.h> int pthread_create(pthread_t *thread, const pthread_a ...
- 线程正常终止pthread_exit,pthread_join,pthread_kill,pthread_cancel,sigwait,sigaddset
int pthread_join(pthread_t thread, void **retval); int pthread_detach(pthread_t thread); void pthrea ...
- pthread_exit pthread_join
int pthread_join(pthread_t thread, void **retval); int pthread_detach(pthread_t thread); void pthrea ...
- pthread_create & pthread_exit
http://www.cppblog.com/saha/articles/189802.html 1. pthread_create #include <pthread.h> ...
- pthread_join/pthread_exit的用法解析
官方说法: 函数pthread_join用来等待一个线程的结束.函数原型为: extern int pthread_join __P ((pthread_t __th, void **__thread ...
- pthread_join/pthread_exit的使用方法解析
官方说法: 函数pthread_join用来等待一个线程的结束.函数原型为: extern int pthread_join __P ((pthread_t __th, void **__thread ...
随机推荐
- 怎么写针对IE9的CSS
(自己亲自试过有用)针对IE9的CSS只需在相应CSS代码加入只有IE9识别的 \9\0.具体代码如下: .div{ background-color:#0f0\9\0;/* ie9 */ } 其他浏 ...
- 北京联想招聘-Android高级工程师(5-7年) 加入qq 群:220486180 或者直接在此 留言咨询
Job ID #: 47979 Position Title: 高级Android开发工程师 Location: CHN-Beijing Functional Area: Research/Devel ...
- Android中对JSONArray数组的指定项进行删除,更新。
首先假设有这么一个JSONArray JSONArray Array1;JSONArray ITEM = new JSONArray(); name为你获取要删除的字段名称,IETM就是你删除后得到的 ...
- http状态码代表含义
状态代码 状态信息 含义 100 Continue 初始的请求已经接受,客户应当继续发送请求的其余部分.(HTTP 1.1新) 101 Switching Protocols 服务器将遵从客户的请求转 ...
- Linux第五次学习笔记
处理器体系结构 Y86指令集体系结构 定义一个指令集体系结构 ,包括定义各种状态元素.指令集和它们的编码.一组编程规范和异常事件处理. 程序员可见的状态 Y86程序中的每条指令都会读取或修改处理器状态 ...
- 学习笔记——Maven实战(八)常用Maven插件介绍(下)
我们都知道Maven本质上是一个插件框架,它的核心并不执行任何具体的构建任务,所有这些任务都交给插件来完成,例如编译源代码是由maven- compiler-plugin完成的.进一步说,每个任务对应 ...
- 去除a标签单击后的虚线框
设置a标签属性outline即可 如: a { outline: none; } a:focus { outline: none; } 在firefox测试通过,webkit内核浏览器无此问题
- jquery-ajax-async之浏览器差异
最近的PC项目遇到了一个问题,日志记录程序会在1s内多次发起对首页的请求,一时间没有找到原因. 简单描述一下问题:访问一个首页的时候,由于代码质量不高的原因,访问就连接数据库,但是同时存在的问题是一秒 ...
- 微信小程序开发:Flex布局
微信小程序页面布局方式采用的是Flex布局.Flex布局,是W3c在2009年提出的一种新的方案,可以简便,完整,响应式的实现各种页面布局.Flex布局提供了元素在容器中的对齐,方向以及顺序,甚至他们 ...
- 关于 hangfire 初始化工作机制
hangfire初始化的配置方法 :UseHangfire . public static class OwinBootstrapper { /// <summary> /// Boots ...