CreateThread和_beginthread

来源:互联网 发布:基于社交网络推荐算法 编辑:程序博客网 时间:2024/06/05 03:24

1、使用_beginthread()或者_beginthreadex()创建线程代替CreateThread()

2、_beginthread()创建线程后,线程结束时会自动清理资源,调用CloseHandle()关闭句柄,如果需要提前结束线程,可调用_endthread()结束线程,_endthread()会调用CloseHandle()关闭句柄

3、_beginthreadex()创建线程后,线程结束时会清理资源,但需要调用调用CloseHandle()关闭句柄,如果需要提前结束线程,可调用_endthreadex(),但需要手工调用CloseHandle()关闭句柄

原创粉丝点击