VC++ calls PostThreadMessage to send messages to threads to realize communication between threads (with source code)

       There are many ways to communicate between threads, such as function callbacks, (anonymous) pipes, sending messages, etc. For Windows multithreading, Windows provides the system API function PostThreadMessage to send messages to the target thread, that is, to achieve multithreading by sending messages. communication between. However, there are some details that need to be paid attention to when using the PostThreadMessage function. This article will introduce them in detail.

 

1. When the function that creates the thread returns, the thread function of the newly created thread does not necessarily run.

       In the Windows system, we can call functions such as CreateThread or __beginthreadex to create a new thread, and specify the thread function corresponding to the thread when calling these functions. When CreateThread or __beginthreadex returns, it only means that the thread was created successfully,

Guess you like

Origin blog.csdn.net/chenlycly/article/details/123965916