multithreaded Programmingterminates the pthread thread
Pthread
is the POSIX threads abbreviation, is POSIX's
Threading Standards.
terminating a thread seems to be the last step in multithreaded programming, but it is by no means the end of this series of textbooks. Thread creation to thread termination, I want to give the reader a general understanding of multithreaded programming.
1. Terminating pthread thread :p thread_exit ()
number of references:
ret: Address pointer, which is essentially the address that the return value is written to.
terminating thread is the thread's active behavior A thread calls Pthread_exit and terminates the thread itself. Thread termination releases Thread-specific data Thread-specific data is thread-exclusive. Because threads share global data, thread exits do not release global data for the process.
The function returns the value how does RET work? The return value is the concept of invocation, so only the return value of a thread is called when there is a thread in it . RET works. This "call" is different from a function call in the general sense, and a thread waits for a thread to be understood as "called." Called by a thread like a Pthread_join
waits for one more thread to terminate. The following describes the wait thread termination function Pthread_join.
2. waiting for thread to terminate :p thread_join ()
The return value of RET is passed through a function pthread_join. Wait for the thread to terminate the Pthread_join prototype as:
waiting for a thread to terminate Pthread_join will block the calling thread until its specified thread terminates. PTHREAD_JOIN specifies a thread by the first parameter: the thread ID. The caller calls Pthread_jion to wait for a particular thread to terminate, in which case the caller may need the return value of this particular thread, Pthread_join gets the return value by assigning the address of the value_ptr to the PTHREAD_EXIT ret of the particular thread.
3.pthread_exi and pthread_join kind :
The example main thread above calls Pthread_join to wait for a child thread to terminate My_thread thread, and to get the return value of the child thread my_thread by passing the My_thread_ret address. Finally, the return value obtained on the screen is output.
"Quad-C + + multithreaded programming Four" terminates pthread thread