I am working on a program that needs
If you are talking about the standard
std::map† and no thread writes to it, no synchronization is required. Concurrent reads without writes are fine.
If however at least one thread performs writes on the map, you will indeed need some sort of protection like a mutex.
Be aware that
std::map::operator counts as write, so use
std::map::find if the key may not exist in the map) instead. You can make the compiler protect you from accidental writes by only referring to the shared map via
†Was clarified to be the case in the OP. For completeness' sake: Note that other classes may have
mutable members. For those, even access through
const& may introduce a race. If in doubt, check the documentation or use something else for parallel programming.