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 Solved by 1 students

Java Concurrency Livelock Example

Mark
< Prev
Next >

Consider the LivelockExample class shown below. Which concurrency issue is demonstrated by the performTask method?

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

Livelock, where threads continuously yield without making progress.

B

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

C

Race condition, where simultaneous access leads to inconsistent data.

D

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

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|