Afxbeginthread和CreateThread之间的差异 [英] Difference between Afxbeginthread and CreateThread

查看:230
本文介绍了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.

,你应该只使用CreateThread,如果你的程序的其余部分也是纯的,原始的Win32,没有使用标准库或MFC。如果你使用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之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆