У вас есть поток 2, ожидающий, пока поток 1 завершит свою работу
нить 1
extern const std::map<int, int>* p;
auto tmp = new std::map<int, int>;
(*tmp)[1] = 2;
...
(*tmp)[2] = 3;
p = tmp;
// set event here
нить 2
extern const std::map<int, int>* p; // suppose p initalized with {{1:2}}
// wait for event here
assert(p->find(1)->second == 2);
или вы можете защитить p с помощью CS или мьютекса в обоих потоках, но затем p следует проверить на достоверность перед использованием в потоке 2
нить 1
extern const std::map<int, int>* p;
auto tmp = new std::map<int, int>;
// lock mutex here
(*tmp)[1] = 2;
...
(*tmp)[2] = 3;
p = tmp;
// unlock mutex here
нить 2
extern const std::map<int, int>* p; // suppose p initalized with {{1:2}}
// lock mutex here
// check if p is initialized:
// if (p is ok){
assert(p->find(1)->second == 2);
// }
// unlock mutex here