Difference between Afxbeginthread and CreateThread(Afxbeginthread 和 CreateThread 的区别)
问题描述
使用 Afxbeginthread 有什么缺点吗?我们什么时候应该使用 AfxBeginThread,什么时候应该使用 CreateThread API.
Is there any drawbacks for using Afxbeginthread. When should we use AfxBeginThread and when should we use CreateThread API.
推荐答案
对于 MFC 程序,使用 AfxBeginThread
.
For MFC programs, use AfxBeginThread
.
CreateThread
是原始的 Win32.它与部分标准库不兼容.
CreateThread
is raw Win32. It's incompatible with parts of the standard library.
_beginthread
是 C 标准库的一部分.它添加了额外的代码来处理标准库的其他部分的线程安全,如果您使用 CreateThread
代替,这些部分将是不安全的.
_beginthread
is part of the C standard library. It adds extra code to handle thread safety for other parts of the standard library that would be unsafe if you used CreateThread
instead.
AfxBeginThread
(显然)是 MFC 的一部分.除了 _beginthread
支持的线程安全之外,它还增加了一些(如果只有少数)C++ 细节.
AfxBeginThread
is (obviously enough) part of MFC. Along with the thread safety supported by _beginthread
, it adds some (if only a few) C++ niceties.
所以,如果你的程序的其余部分也是纯的、原始的 Win32,不使用标准库或 MFC,你应该只使用 CreateThread.如果您使用的是 MFC,通常应该使用 AfxBeginThread
而不是 CreateThread
.
So, you should only use CreateThread if the rest of your program is also pure, raw Win32, with no use of the standard library or MFC. If you're using MFC otherwise, you should normally use AfxBeginThread
rather than CreateThread
.
这篇关于Afxbeginthread 和 CreateThread 的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Afxbeginthread 和 CreateThread 的区别


基础教程推荐
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 这个宏可以转换成函数吗? 2022-01-01
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 我有静态或动态 boost 库吗? 2021-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 常量变量在标题中不起作用 2021-01-01