Windows threading: _beginthread vs _beginthreadex vs CreateThread C++

后端 未结 17 1462
臣服心动
臣服心动 2020-11-22 17:26

What\'s a better way to start a thread, _beginthread, _beginthreadx or CreateThread?

I\'m trying to determine what are the adv

17条回答
  •  醉梦人生
    2020-11-22 17:37

    In general, the correct thing to do is to call _beginthread()/_endthread() (or the ex() variants). However, if you use the CRT as a .dll, the CRT state will be properly initialized and destroyed as the CRT's DllMain will be called with DLL_THREAD_ATTACH and DLL_THREAD_DETACH when calling CreateThread() and ExitThread() or returning, respectively.

    The DllMain code for the CRT can be found in the install directory for VS under VC\crt\src\crtlib.c.

提交回复
热议问题