1.pthread_cleanup_push
- 功能:清理函数
- 原型:
void pthread_cleanup_push(void (*routine)(void *), void * arg);
- 参数:
1)void (*routine) (void*)
执行:
a.显式调用:pthread_exit
b.线程被取消:pthread_cancel
c.清理处理函数被弹出:pthread_cleanup_pop(1),\会立刻执行相应的清理函数,但线程暂未被终止,直到 pthread_exit() 或 start_routine 返回
2)void* args - 返回值:
无返回值
2.pthread_cleanup_pop
- 功能:清理函数
- 原型:
void pthread_cleanup_pop(int execute);
- 参数:
1)int execute:0,不执行;非0,执行 - 返回值:
无返回值
执行时机:
1)调用 pthread_exit()
2)响应取消请求
3)调用 pthread_cleanup_pop(1),不会导致线程终止
注意事项:
1)从 sta