std::mutex
`std::mutex` is a synchronization primitive in C++ that helps manage access to shared resources in a multithreaded environment. It prevents multiple threads from simultaneously accessing the same resource, which can lead to data corruption or unexpected behavior. By locking a mutex, a thread ensures that it has exclusive access to the resource until it unlocks the mutex.
When a thread attempts to lock a `std::mutex` that is already locked by another thread, it will be blocked until the mutex becomes available. This mechanism is crucial for maintaining data integrity and ensuring that threads operate safely without interfering with each other.