Simply:
AfxBeginThread is the global function of MFC, which is the encapsulation of CreateThread.
CreateThread is the Win32 API function, which is eventually transferred to the latter.
1>.
Specifically, the CreateThread function is the API function that Windows provides to the user, which is the standard form of the SDK, used in the
Process to take into account the synchronization and mutual exclusion of processes, inter-process synchronization mutually exclusive, such as a series of factors that lead to the deadlock of the operating system, use up
More cumbersome, beginners in the use of the time may produce unpredictable errors, it is recommended to use AfxBeginThread, is compiled
The original CreateThread function is encapsulated with MFC programming (of course, as long as the project properties are modified, the console and the Win32 project
can be called) and _beginthread is the run-Library function of C.
2>
When using AfxBeginThread,
The thread function is defined as: the
UINT _yourthreadfun (LPVOID pparam) parameter must be so
When using CreateThread,
The function of the thread is defined as:
DWORD WINAPI _yourthreadfun (lpvoid pparameter)
The two are essentially the same,
However, AfxBeginThread returns the CWinThread pointer, which means that it will be a new CWinThread object, and this object will be deleted automatically at the end of the thread run.
Creatthread, it returns a handle, and if you don't use CloseHandle, you can safely understand the thread state,
Closehandle,windows only releases resources when it's not the last time.
The difference between multithreading AfxBeginThread and CreateThread