"Quad-C + + multithreaded programming Four" terminates pthread thread

Source: Internet
Author: User
Tags posix

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.