No, they are not thread safe. Standard containers are simply not thread safe, period.
However, there is a limited degree of thread safety: if each thread accesses another element and no element accesses two separate threads at any given time, then this is fine. However, any operation that mutates the container itself (insertion, erasure) is not thread safe and should be synchronized. Consequently, iterators and links can lose their relevance, as well as size() .
In other words, if you separate all operations that mutate the container from those that don't, then as long as you don't mutate, you can safely call size() from multiple threads.
source share