【Linux系统编程】线程_01_线程基本API_06_线程清理cleanup_push&cleanup_pop

1.pthread_cleanup_push

  1. 功能:清理函数
  2. 原型
void pthread_cleanup_push(void (*routine)(void *), void *  arg);
  1. 参数
    1)void (*routine) (void*)
    执行:
    a.显式调用:pthread_exit
    b.线程被取消:pthread_cancel
    c.清理处理函数被弹出:pthread_cleanup_pop(1),\会立刻执行相应的清理函数,但线程暂未被终止,直到 pthread_exit() 或 start_routine 返回
    2)void* args
  2. 返回值
    无返回值

2.pthread_cleanup_pop

  1. 功能:清理函数
  2. 原型
void pthread_cleanup_pop(int execute);
  1. 参数
    1)int execute:0,不执行;非0,执行
  2. 返回值
    无返回值

执行时机
1)调用 pthread_exit()
2)响应取消请求
3)调用 pthread_cleanup_pop(1),不会导致线程终止

注意事项
1)从 sta

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值