All challenges
Multiple ChoiceIntermediate 45s

Why condition_variable wait needs a predicate loop

Why must condition_variable::wait be used with a predicate (or in a loop) rather than a bare wait?
Options
  1. 1Because the mutex otherwise remains locked forever
  2. 2Because the predicate increases the priority of the waiting thread
  3. 3Because wait can return spuriously and the predicate re-checks the condition
  4. 4Because std::condition_variable requires a predicate to compile

Think you can answer under pressure?

Get matched and answer live questions in 3-minute 1v1 battles. Elo ranking, badge tiers and bragging rights on the line.

Play this in a 3-minute battle