Login to manage your account

Please enter a valid email address.
Forgot Password?
Please enter a valid password.
OR

Don't have an account yet? Sign up

Which RAII wrapper should be used to lock a std::mutex?

  1. A Calling lock() and unlock() manually
  2. B std::lock_guard or std::unique_lock
  3. C std::atomic
  4. D std::thread
Answer

std::lock_guard or std::unique_lock

RAII locking releases the mutex even if an exception propagates. Manual unlocking is skipped when an exception is thrown.

All C++ MCQs

Login to manage your account

Please enter a valid email address.
Forgot Password?
Please enter a valid password.
OR

Don't have an account yet? Sign up as