在线程中运行函数

编程入门 行业动态 更新时间:2024-10-25 20:22:21
本文介绍了在线程中运行函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想执行上述操作。

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".

更多推荐

在线程中运行函数

本文发布于:2023-11-23 10:34:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1621122.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:线程   函数

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!