Are find and read operations on std::map threadsafe? [duplicate]

雨燕双飞 提交于 2019-12-24 08:45:56

问题


Possible Duplicate:
Thread safety of std::map for read-only operations

Having std::map a can we do a.find(...)->second in multiple threads at the same time on it?


回答1:


Yes. As long as none of your threads do a write

i.e. Construct the data structure in memory

Use as many threads to find/read as you require.

If the leaf needs altering put a mutex there.



来源:https://stackoverflow.com/questions/7198332/are-find-and-read-operations-on-stdmap-threadsafe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!