博客
关于我
线程的退出
阅读量:317 次
发布时间:2019-03-04

本文共 556 字,大约阅读时间需要 1 分钟。

线程退出函数

pthread_exit
线程退出注意事项:
在线程中使用pthread_exit
在线程中使用return(主控线程return代表退出进程)
exit代表退出整个进程

pthread_exit.c

#include 
#include
#include
#include
void* thr(void *arg){ printf("I am a thread! pid=%d,tid=%lu\n",getpid(),pthread_self()); //return NULL; pthread_exit(NULL); exit(1);}int main(){ pthread_t tid; pthread_create(&tid,NULL,thr,NULL); printf("I am a main thread! pid=%d,tid=%lu\n",getpid(),pthread_self()); sleep(3); printf("I will out\n"); pthread_exit(NULL); return 0;}

转载地址:http://lrwh.baihongyu.com/

你可能感兴趣的文章
全局锁和表锁 :给表加个字段怎么有这么多阻碍?
查看>>
二分查找与插入排序的结合使用
查看>>
892 三维形体的表面积(分析)
查看>>
279 完全平方数(bfs)
查看>>
875 爱吃香蕉的珂珂(二分查找)
查看>>
第十一届蓝桥杯python组第二场省赛-数字三角形
查看>>
BST中某一层的所有节点(宽度优先搜索)
查看>>
Eclipse导出项目出现resource is out of sync with the file...错误
查看>>
Dijkstra算法的总结
查看>>
Vue实现选项卡功能
查看>>
vue中接收后台的图片验证码并显示
查看>>
Vue入门学习笔记(1)
查看>>
趣谈win10常用快捷键
查看>>
数学建模更新12(数学线性规划模型1)
查看>>
Android,SharedPreferences的使用
查看>>
两款用于检测内存泄漏的软件
查看>>
王爽 《汇编语言》 读书笔记 三 寄存器(内存访问)
查看>>
IDEA出现问题:Received fatal alert: protocol_version 解决方案
查看>>
Airtest自动化测试 Docs airtest.core.android package
查看>>
JDK 内置的多线程协作工具类的使用场景
查看>>