博客
关于我
线程的退出
阅读量:320 次
发布时间: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/

你可能感兴趣的文章
Netty工作笔记0026---NIO 网络编程应用--群聊系统1---编写服务器1
查看>>
Netty工作笔记0027---NIO 网络编程应用--群聊系统2--服务器编写2
查看>>
Netty工作笔记0028---NIO 网络编程应用--群聊系统3--客户端编写1
查看>>
Netty工作笔记0029---NIO 网络编程应用--群聊系统4--客户端编写2
查看>>
Netty工作笔记0030---NIO与零拷贝原理剖析
查看>>
Netty工作笔记0031---NIO零拷贝应用案例
查看>>
Netty工作笔记0032---零拷贝AIO内容梳理
查看>>