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

Quiz: Java Multithreading · Question 3 of 10

Why can count++ give wrong results with two threads?

Why can count++ give wrong results with two threads?

  1. A.++ is not allowed in threads
  2. B.It is read-modify-write, so updates from two threads can overlap and be lost
  3. C.int can't be shared
  4. D.Java runs one thread at a time
Answer & explanation

Correct answer: It is read-modify-write, so updates from two threads can overlap and be lost

Without synchronization, both threads can read the same old value.

Can you get the rest right without peeking?

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

Start the quiz →