windows创建线程一般都使用CreateThread,该函数与CRT有冲突,尽量不要使用该函数,应该用_beginthread,结束线程用_endthread,这两个函数可以成套的使用。
使用这两个函数需要包含的头文件 #include
_beginthread声明如下ACRTIMP uintptr_t __cdecl _beginthread(
_In_ _beginthread_proc_type _StartAddress,
_In_ unsigned _StackSize,
_In_opt_ void* _ArgList
);
参数说明
_StartAddress 线程函数地址,格式如下:
typedef void (__cdecl* _beginthread_proc_type )(void*);
其实就是 void ThreadFun(void* param)这种形式
_StackSize 栈大小,同CreateThread, 一般填0
_ArgList 参数列表,无参数时设为NULL
返回值成功返回新建线程的句柄,需要使用reinterpret_cast强制转换&