Windows threading: _beginthread vs _beginthreadex vs CreateThread C++

后端 未结 17 1468
臣服心动
臣服心动 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:41

    CreateThread() is a raw Win32 API call for creating another thread of control at the kernel level.

    _beginthread() & _beginthreadex() are C runtime library calls that call CreateThread() behind the scenes. Once CreateThread() has returned, _beginthread/ex() takes care of additional bookkeeping to make the C runtime library usable & consistent in the new thread.

    In C++ you should almost certainly use _beginthreadex() unless you won't be linking to the C runtime library at all (aka MSVCRT*.dll/.lib).

提交回复
热议问题