🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Java Concurrency Utilities: all 10 questions

Quiz: Java Concurrency Utilities · Question 3 of 10

What does compare-and-set (CAS) do?

What does compare-and-set (CAS) do?

  1. A.Sets a new value only if the current value still equals the expected value
  2. B.Locks the variable until the thread ends
  3. C.Compares two objects with equals
  4. D.Sorts values before setting them
Answer & explanation

Correct answer: Sets a new value only if the current value still equals the expected value

If another thread changed the value in between, CAS fails and the caller retries with the fresh value.

Can you get the rest right without peeking?

Take the timed Quiz: Java Concurrency Utilities quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →