本文介绍了在线程中运行函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想执行上述操作。
void myFunc() { ... // several stuff } ... int main() { ... // I would like to run myFunc in a thread so that the code below could execute // while it is being completed. ... }你建议我应该怎么办?
What do you suggest I should do? Which function call from which library would enable me to complete my goal?
推荐答案对于Win32编程,您可以使用 beginthread 。还有 CreateThread ,但如果我记得正确,那不会初始化C / C ++环境,这会导致问题。
For Win32 programming, you can use beginthread. There is also CreateThread, but if I remember correctly, that doesn't initialize the C/C++ environment, which leads to problems.
编辑:刚刚选中 - MSDN状态可执行文件中调用C运行时库(CRT)的线程应该使用_beginthread和_endthread函数的线程管理,而不是CreateThread和ExitThread。
Just checked - MSDN states "A thread in an executable that calls the C run-time library (CRT) should use the _beginthread and _endthread functions for thread management rather than CreateThread and ExitThread".
更多推荐
在线程中运行函数
发布评论