Change to std::mutex for synchronization.