| preferred AP College board partner for AP classes
AP Computer Science A/Unit 5: Writing Classes
Start Practice TestPractice Test
About Exam
hard Solved by 2 students
Java Concurrency Livelock Example
< Prev
Next >

What concurrency issue does the LivelockExample class illustrate?

public class LivelockExample {
    public void performTask() {
        while (true) {
            if (tryToCompleteTask()) {
                break;
            }
            Thread.yield();
        }
    }
    
    public boolean tryToCompleteTask() {
        // Simulate repeated failure to complete the task
        return false;
    }
}
A

Thread starvation, where low-priority threads never get executed.

B

Deadlock, where threads permanently wait for each other’s resources.

C

Race condition, where simultaneous access leads to inconsistent data.

D

Livelock, where threads continuously yield without making progress.

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.

No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: [email protected]|Privacy Policy