C++11 STL containers and thread safety

前端 未结 3 1178
野性不改
野性不改 2020-11-28 03:57

I have trouble finding any up-to-date information on this.

Do C++11 versions of STL containers have some level of thread safety guaranteed?

I do expect that

3条回答
  •  無奈伤痛
    2020-11-28 04:52

    I think STL containers offer the following basic thread-safety guarantee:

    • simultaneous reads of the same object are OK

    • simultaneous read/writes of different objects are OK

    But you have to use some form of custom synchronization (e.g. critical section) if you want to do something different, like e.g. simultaneous writes on the same object.

提交回复
热议问题