我们如何在C ++中创建线程? [英] how can we create a thread in C++?

查看:133
本文介绍了我们如何在C ++中创建线程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们如何在C ++中创建线程?

How can we create a thread in C++?

推荐答案

线程库依赖于平台(*),例如在Windows上,您通常使用 CreateThread函数 [ pthread_create函数 [^ ].


如果您需要可移植性,请查看 Boost.Threads [ ^ ].
Thread libraries are platform dependent (*), for instance on Windows you typically use CreateThread function[^] while on Linux you would use POSIX threads'' pthread_create function[^].


If you need portability then have a look at Boost.Threads[^].


我认为在Windows中使用_beginthreadex是更好的选择.请参考这个.

http://msdn.microsoft.com/en-us/library/kdzttdcb (v = vs.80).aspx [
I think in Windows using _beginthreadex is better option. Please refer this.

http://msdn.microsoft.com/en-us/library/kdzttdcb(v=vs.80).aspx[^]


该网站可以为您提供帮助

http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html [
this site could help you

http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html[^]


这篇关于我们如何在C ++中创建线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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