advanced linux programming note
1.pthread_create function creates thread that share the same memory with the process.
2.pthread_join function wait for threads until they stop
3.The pthread_self function returns the thread ID of the thread in which it is
called;This thread ID may be compared with another thread ID using the
pthread_equal function
1 if (!pthread_equal (pthread_self (), other_thread)) 2 pthread_join (other_thread, NULL);
4.one of thread‘s important attribute is the detach state,which includes joinable state(default) and detached thread.the difference is that the joinable thread is not automatically cleaned up by GNU/Linux when it terminates,but needs pthread_join to do the clean up.A detached thread is just the opposite.
Even if a thread is created in a joinable state, it may later be turned into a detached thread.To do this, call pthread_detach . Once a thread is detached, it cannot be made joinable again.
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。