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

你可能感兴趣的文章
mysql 导入导出大文件
查看>>
MySQL 导出数据
查看>>
mysql 将null转代为0
查看>>
mysql 常用
查看>>
MySQL 常用列类型
查看>>
mysql 常用命令
查看>>
Mysql 常见ALTER TABLE操作
查看>>
MySQL 常见的 9 种优化方法
查看>>
MySQL 常见的开放性问题
查看>>
Mysql 常见错误
查看>>
mysql 常见问题
查看>>
MYSQL 幻读(Phantom Problem)不可重复读
查看>>
mysql 往字段后面加字符串
查看>>
mysql 快照读 幻读_innodb当前读 与 快照读 and rr级别是否真正避免了幻读
查看>>
MySQL 快速创建千万级测试数据
查看>>
mysql 快速自增假数据, 新增假数据,mysql自增假数据
查看>>
MySql 手动执行主从备份
查看>>
Mysql 批量修改四种方式效率对比(一)
查看>>
mysql 批量插入
查看>>
Mysql 报错 Field 'id' doesn't have a default value
查看>>