C++ 如何使用 Win32 API 创建线程?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7260284/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to create threads with Win32 API?
提问by bodacydo
I have written a TCP server with Win32 API and C++ but it's single-threaded. Can anyone tell me how would I go about making it multi-threaded? I imagine for every new accepted connection, I'd have to spawn a thread that takes care of it. But I have never had experience with threading in Win32. Can anyone tell me how I would go about threaded programming with Win32 and C++?
我用 Win32 API 和 C++ 编写了一个 TCP 服务器,但它是单线程的。谁能告诉我如何使它成为多线程?我想对于每个新接受的连接,我都必须生成一个线程来处理它。但是我从来没有在 Win32 中使用线程的经验。谁能告诉我如何使用 Win32 和 C++ 进行线程编程?
采纳答案by Nawaz
Read the documentation of :
阅读以下文档:
And you can also see an example in my answer here:
你也可以在我的回答中看到一个例子: