Possible Duplicate:
Is stl vector concurrent read thread-safe?
I have a multi-threaded program that has a certain amount of workers, each worker has a ‘workerID’ which is essentially just a unique integer for that thread. I want to use a vector of structs to manage these threads. my question is, if thread 4 wants to access myVector[4] at the same time as thread 8 wants to access myVector[8], am I going to have a problem?
If you have setup the vector before entering into multi-threading scenario, and then you want to only read the vector from multiple threads, without modifying it, then it is thread-safe. You can read even the same element from more than two threads simultaneously, just make sure that no thread modifies the vector in any way. Treat the vector and all its elements as read-only.
However, for modification, none of the containers from the Standard Library are thread-safe. You need to implement the synchronization yourself.
C++11 has introduced many synchronization primitives, so if your compiler supports, you can use them.