当前位置:网站首页>Thread support
Thread support
2022-06-24 07:47:00 【Fog dispels eyesight】
Thread support
c Standard library :
c The standard library does not have thread support , Use platform native functions :
windows:CreateThread
unix:pthread_create In fact, threads are simulated by processes .
c++ Standard library
operator= Only right values are supported as parameters , The use of move The original thread object is changed to non joinable
get_id Get thread id
joinable Check whether the thread can wait , Empty thread Objects are not waiting .
join Wait for thread execution to complete .
detach Separate the thread object from the thread , here thread Object does not represent a thread , The thread continues to execute .
swap In exchange for
native_handle Get the thread handle of the native platform .
this_thread:
get_id Gets the current thread's id
yield Discard the time slice of the current thread amount to sleep(0)
sleep_until: Sleep
sleep_for: Sleep
Find... From above thread It has been executed since its creation , No, start、stop、pause、resume Such behavior .
Example :
// thread example
#include <iostream> // std::cout
#include <thread> // std::thread
void foo()
{
// do stuff...
}
void bar(int x)
{
// do stuff...
}
int main()
{
std::thread first (foo); // spawn new thread that calls foo()
std::thread second (bar,0); // spawn new thread that calls bar(0)
std::cout << "main, foo and bar now execute concurrently...\n";
// synchronize threads:
first.join(); // pauses until first finishes
second.join(); // pauses until second finishes
std::cout << "foo and bar completed.\n";
return 0;
}
boost library :
See :
<boost/thread/thread.hpp>
边栏推荐
- opencvsharp二值图像反色
- Blue Bridge Cup seven segment code (dfs/ shape pressing + parallel search)
- Knowledge points of 2022 system integration project management engineer examination: ITSS information technology service
- 鸿蒙os开发三
- Tidb operator source code reading (IV) control cycle of components
- [understanding of opportunity -29]: Guiguzi - internal dialogue - five levels of communication with superiors
- 站在风暴中心:如何给飞奔中的腾讯更换引擎
- Tencent cloud security and privacy computing has passed the evaluation of the ICT Institute and obtained national recognition
- Error "computing failed in `stat\u summary\u hex() `"
- 位运算
猜你喜欢

用Ngrok 配置属于自己的免费外网域名

Combine with (& &) logic or (||), dynamic binding and ternary operation

屏幕截图推荐—Snipaste

GPU is not used when the code is running
![(cve-2020-11978) command injection vulnerability recurrence in airflow DAG [vulhub range]](/img/33/d601a6f92b1b73798dceb027263223.png)
(cve-2020-11978) command injection vulnerability recurrence in airflow DAG [vulhub range]

Alibaba cloud full link data governance

More than 60 million shovel excrement officials, can they hold a spring of domestic staple food?

保留一位小数和保留两位小数

图形技术之管线概念

Error:Kotlin: Module was compiled with an incompatible version of Kotlin. The binary version of its
随机推荐
Hongmeng OS development III
随机数备注
Knowledge points of 2022 system integration project management engineer examination: ITSS information technology service
Global and Chinese market of offshore furnaces 2022-2028: Research Report on technology, participants, trends, market size and share
A summary of the posture of bouncing and forwarding around the firewall
Common coding and encryption in penetration testing
Unity Culling 相关技术
Deploy L2TP in VPN (Part 1)
Black box and white box models for interpretable AI
Domain environment importing Tencent cloud considerations
Cloud development who is the source code of undercover applet
OpenGauss数据库在 CentOS 上的实践,配置篇
[Lua language from bronze to king] Part 2: development environment construction +3 editor usage examples
屏幕截图推荐—Snipaste
Climbing 10000 NASA pictures about Mars exploration, I found a secret
力扣(LeetCode)174. 地下城游戏(2022.06.23)
Exness: Powell insisted on his anti inflation commitment and pointed out that recession is possible
日期、时间库使用备注
10 common malware detection and analysis platforms
云开发谁是卧底小程序源码