Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
AP Computer Science A/Unit 5: Writing Classes
Start Practice TestPractice Test
About Exam
hard

Java Volatile Keyword and Atomicity

Mark
< Prev
Next >

Consider the VolatileFlag class provided. Although the done variable is declared as volatile, what concurrency issue still exists within the checkAndReset() method?

public class VolatileFlag {
    private volatile boolean done = false;
    
    public void checkAndReset() {
        if (done) {
            done = false;
        }
    }
}
A

Race condition due to the non-atomic check-and-act operation.

B

Deadlock because volatile variables can induce locking issues.

C

Compilation failure due to improper volatile usage.

D

Memory visibility problems remain unresolved.

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question

Question Leaderboard

Not enough data yet to show leaderboard.

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy|