dimanche 16 juillet 2017

Multithreading involving different operations on a shared resourse (vector) in C++

I've a vector of strings which is a shared resourse.

std::vector<std::string> vecstr;

Have 2 threads which run in parallel: Thread1: To insert strings to shared resourse. Thread2: To calculate the size of the shared resourse.

Both the threads are doing different operations on a shared resourse. Do we still need to mutex protect "vecstr".

Aucun commentaire:

Enregistrer un commentaire