关于pthread_detach(pthread_self())

来源:互联网 发布:淘宝网货到付款网站 编辑:程序博客网 时间:2024/05/29 11:40

被创建的子线程也可以自己分离自己,子线程调用pthread_detach(pthread_self())就是分离自己,因为pthread_self()这个函数返回的就是自己本身的线程ID。


目的:该子线程止时底层资源立即被回收,防止内存不能释放造成内存泄露。