大家好,我想知道线程安全数据和线程安全容器之间的区别
发布于 2009-06-16 05:28:33
线程安全数据
- It can be _modified_ from multiple threads in a controlled manner, to ensure the resultant data structure doesn't becoming corrupt, or lead to race conditions in the code.
- It can be _read_ in a reliable fashion without the data become corrupt during the read process. This is especially important with STL-style containers which use iterators.
- It is bad practice to make any assumptions about CPU architecture.
- You should always code defensively to ensure code will remain thread-safe regardless of the target platform.
线程安全容器
互斥锁容器是一些容器,它们具有确保对它们所做的任何更改都以线程安全的方式发生的适当措施。例如,线程安全容器可以允许使用一组特定的公共方法来插入或删除项,这些方法确保使用它的任何代码都是thread-safe.
https://stackoverflow.com/questions/999699
复制相似问题