All challenges
Multiple ChoiceHard 45s

compare_exchange_weak vs strong

What is the practical difference between `compare_exchange_weak` and `compare_exchange_strong`?
Options
  1. 1Weak is the stronger form and never fails spuriously, while strong may fail even on a match.
  2. 2Weak may spuriously fail even when the value matches (requires a loop), but can be faster on LL/SC architectures; strong never spuriously fails.
  3. 3They are identical in behavior and differ only in the default memory ordering they assume.
  4. 4strong is only usable together with seq_cst ordering, while weak accepts any memory order.

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