CreateThread, AfxBeginThread,_beginthread, _beginthreadex的区别

(一)

1、CreateThread是系统创建线程的接口,而AfxBeginThread,_beginthread, _beginthreadex,而只是为了程序的要求,而做的封装与拓展。

2、在MFC中,最好用AfxBeginThread来创建,因为它返回的是CWinThread类,这个类可以用来响应消息,于是它既可以做工作线程,也可以做界面线程,所以,AfxBeginThread是MFC中最好的选择。

3、_beginthreadex是对_beginthread的扩展,并且对_beginthread中存在的bug进行修复。

4、_beginthreadex相对于CreateThread增加了:

  1、创建了一个_tiddata数据来

  2、释放 _tiddata

  3、增加了一个SEH(异常处理)

(二)

AfxBeginThread的线程函数声明:     UINT  _yourThreadFun(LPVOID   pParam)

CreateThread的线程函数声明:        DWORD  WINAPI  _yourThreadFun(LPVOID pParameter)

原文地址:https://www.cnblogs.com/wang-can/p/3338100.html