← 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?
- A.++ is not allowed in threads
- B.It is read-modify-write, so updates from two threads can overlap and be lost
- C.int can't be shared
- 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 →