<分区>
假设有
class concurr{
public:
double arr[100];
void func1(vector<vector<double>> data,int x);
double func2(vector<vector<double>> data);
}
这样 func2 接受“数据”并将其提供给 func1 相同的“数据”但 x 的数量从 0 到 100 不等。然后在 func1 中,它计算一些东西以及它的 double 值出来,为 arr[x] 填充所以基本上,func2 看起来一般像
double concurr::func2(vector<vector<double>> data){
thread threads[100];
for (int x = 0; x < 100; x++){
threads[x] = thread(concurr::func1,data,x); // this line is where the problem is
}
for (auto& th : threads){
th.join();
}
// ..... does something with the arr[100].... to come up with double = value
return value;
}
没有多线程部分,代码运行良好,只是添加了多线程部分,当我尝试编译时,它说 “对非静态成员函数的引用必须是 叫“