摘要:
#include<iostream> #include<thread> #include<mutex> #include<atomic> using namespace std; mutex g_mutex; atomic<bool> isok = false; void func(int id) 阅读全文
posted @ 2020-05-28 18:55
知道了呀~
阅读(287)
评论(0)
推荐(0)
摘要:
在许多时候,我们会有这样的需求——即我们想要得到线程返回的值。但是在C++11 多线程中我们注意到,std::thread对象会忽略顶层函数的返回值。 那问题来了,我们要怎么获得线程的返回值呢? 我们通过一个例子来说明如何实现这个需求。用多个线程计算(a+b)/ (x+y) 的值 有两种方法,分别是 阅读全文
posted @ 2020-05-28 18:27
知道了呀~
阅读(6202)
评论(0)
推荐(0)

浙公网安备 33010602011771号