linux thread笔记总结

1、结束线程的两种方法

     1、一种是线程自己结束自己, 然后调用 pthread_attr_destroy、pthread_exit()

     2、一种是别的线程结束, 调用pthread_cancel, 如果线程是Joineable, 则要调用pthread_join阻塞等待, 非joinenable, 

如果,这时可以在子线程中加入代码 
pthread_detach(pthread_self()) 
或者父线程调用 
pthread_detach(thread_id)(非阻塞,可立即返回) 

posted @ 2021-06-08 10:36  cogitoergosum  阅读(88)  评论(0编辑  收藏  举报