博客
关于我
线程的退出
阅读量: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/

你可能感兴趣的文章
后缀树
查看>>
Java高性能编程之CAS与ABA及解决方法
查看>>
从BIO到Netty的演变
查看>>
《算法导论》第二章笔记
查看>>
HTML `capture` 属性
查看>>
CSS盒子模型
查看>>
HTML节点操作
查看>>
浏览器页面呈现过程
查看>>
HTML5新特性
查看>>
async/await剖析
查看>>
常见的兼容性问题
查看>>
cmp命令
查看>>
一次编辑
查看>>
od命令
查看>>
简单工厂模式
查看>>
代理模式
查看>>
read命令
查看>>
Js中Currying的应用
查看>>
长按键入
查看>>
Vuex和普通全局对象
查看>>