You need to synchronize access to the container if multiple threads are accessing the container, and at least one of these threads modifies the contents of the container. If none of the threads ever changes the contents of the container, you do not need to synchronize access with it.
[Note that the C ++ language standard does not mention streams (at least not yet), so it is not required that containers can be used from multiple streams. However, what I said above is true, at least for all major implementations of the standard library, and is a requirement in the upcoming version of C ++ 0x for the C ++ language standard.]
source share