我要执行上述操作。
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.
...
}
你建议我应该做什么?来自哪个库的哪个函数调用将使我能够完成我的目标?
最佳答案
对于Win32编程,可以使用beginthread
。还有 CreateThread
,但如果我没记错的话,它不会初始化 C/C++ 环境,这会导致问题。
编辑:刚刚检查过 - MSDN 声明“调用 C 运行时库 (CRT) 的可执行文件中的线程应该使用 _beginthread 和 _endthread 函数进行线程管理,而不是 CreateThread 和 ExitThread”。
关于c++ - 在线程中运行函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7947561/