在以下三种情况下 , pthread_cleanup_pop ( )压栈的"清理函数" 会被调用:
1 . 线程调用 pthread_exit ( )函数 , 而不是直接 return .
1 . 线程调用 pthread_exit ( )函数 , 而不是直接 return .
2. 响应取消请求时,也就是有其它的线程对该线程调用 pthread_cancel ( ) 函数 .
3. 调用 pthread_cleanup_pop ( )时,其参数非零 .
3. 调用 pthread_cleanup_pop ( )时,其参数非零 .
注意:
1. 当 pthread_cleanup_pop ( )的参数为0 时,仅仅在线程调用thread_exit ( )函数时或者其它线程对本线程调用
pthread_cancel ( )函数时 , 才在弹出 "清理函数" 的时候并同时执行该 "清理函数" .
2 . 注意 pthread_exit ( )终止线程与线程直接return终止线程的区别 , 调用return是不会在弹出 " 清理函数" 的同时并执行该 " 清理函数" 的 .
1. 当 pthread_cleanup_pop ( )的参数为0 时,仅仅在线程调用thread_exit ( )函数时或者其它线程对本线程调用
2 . 注意 pthread_exit ( )终止线程与线程直接return终止线程的区别 , 调用return是不会在弹出 " 清理函数" 的同时并执行该 " 清理函数" 的 .