Update main.cpp

using std::mutex for synchronization