WIN32 Multi-Threading is created mainly by:
CreateThread ()
_beginthread () &&_beginthreadex ()
AfxBeginThread ()
CWinThread class
First, Introduction
CreateThread: WIN32 provides the most basic API for creating threads that are used to create a thread on the main thread. Returns a handle handle (kernel object). After the kernel objects are used, it is generally necessary to close, using the CloseHandle () function.
_beginthread () &&_beginthreadex (): _beginthreadex () can simply think of _beginthread () as its simplified version, so more often it is easier to use _beginthread ()
In MSDN, you can see an important note, "for a executable file linked with Libcmt.lib, does not call the Win32 exitthread API; This prevents the Run-time system from reclaiming allocated resources. _endthread and _endthreadex reclaim allocated thread resources and then call ExitThread. "Simple translation means, For the executable program that links Libcmt.lib, do not use Win32 's thread Exit Function (ExitThread), which prevents the runtime system from reclaiming allocated resources and should use _endthread. It can reclaim the allocated thread resources and then call ExitThread. This question does not seem to mention CreateThread (), but in fact, this is often seen in some of the information on the "Do not use CreateThread to create threads, otherwise memory leaks " source.
See http://wenku.baidu.com/view/adede4ec4afe04a1b071dea4.html for more detailed information
AfxBeginThread: This is the AFX series function in MFC, a global function that creates threads in MFC.
Cwinthread:ui thread, can receive message, need to call AfxBeginThread create thread.
AfxBeginThread (Runtime_class (MyThread))
Second, some parameters introduced
Dwstacksize: Thread stack size, using 0 with default settings, defaults to 1024K, so you can only create less than 2048 threads (2G of memory) by default. Windows dynamically increases the stack size as needed.
Lpthreadattributes: Thread properties.
Lpstartaddress: A pointer to a thread function.
Lpparameter: The arguments passed to the thread function.
dwCreationFlags: Thread Flag, create_suspended represents the creation of a suspended thread, 0 means that the thread is activated immediately after creation.
Lpthreadid, first thread ID (output parameter)
Win32 How to create a multi-threading method, Difference and contact