Possible Duplicate:
STL vector and thread-safety
If I have this piece of code:
std::vector<std::vector<double>> a;
std::vector<double> b;
// init a,b....
std::vector<double> c;
parallel_for_each (a.begin(); a.end; [&c, &b] (std::vector<double>& aux) {
c.push_back(foo(b, aux));
});
It is thread safe to add elements like that in the vector ?
No,
std::vectoris not thread-safe. You have to provide synchronization.