cancel
Showing results for 
Search instead for 
Did you mean: 

STL Using Threads

 
SOLVED
Go to solution
Highlighted
Occasional Visitor

STL Using Threads

Looking at aC++ online programmers guide (A06.05) it seems that the stl library (v2) are thread safe (-mt switch), but using from multiple threads the same queue object with push and pop calls the program ended, however if we protect the calls via mutex the program complete succesfully. Looking inside the template code there are no mutexes, this make me thing that the STL are not thread safe.
Any comment? Thanks and regards, Ivano
1 REPLY 1
Highlighted
Solution

Re: STL Using Threads

STL containers are only thread safe behind the user's back. (In particular the reference counted strings.)

But the user is responsible synchronizing his own accesses and modifications to his containers. The same as if you were dealing with an int.

Accessing separate STL containers is safe.