2 Star 5 Fork 1

beth/ConcurrencySample

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
thread_4.cpp 594 Bytes
一键复制 编辑 原始数据 按行查看 历史
beth 提交于 2021-02-07 11:52 . Submit sample code.
/**
* @file thread_4.cpp
* @brief תȨ
*/
#include <iostream>
#include <thread>
using namespace std;
thread fun1()
{
auto foo = []() { cout << "fun1" << endl; };
return thread(foo);
}
void fun2(thread t)
{
cout << "fun2" << endl;
t.join();
}
int main()
{
thread t1([]() {
cout << "thread begin." << endl;
});
thread t2 = move(t1);
thread t3 = move(t2);
cout << t2.joinable() << endl;
cout << t3.joinable() << endl;
t3.join();
thread t4 = fun1();
t4 = move(t3);
t4.join();
thread t5([]() { cout << "do something." << endl; });
fun2(move(t5));
return 0;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/bethjohanssen/concurrency-sample.git
git@gitee.com:bethjohanssen/concurrency-sample.git
bethjohanssen
concurrency-sample
ConcurrencySample
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385