| 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 Thread Interruption Behavior
< Prev
Next >

If a thread running InterruptExample is interrupted during wait(), what will be the outcome?

public class InterruptExample implements Runnable {
    public void run() {
        synchronized(this) {
            try {
                wait();
            } catch (InterruptedException e) {
                System.out.println("Interrupted!");
            }
        }
    }
}
A

It will cause the program to terminate immediately.

B

It will silently resume execution without any notification.

C

It will throw an InterruptedException, catch it, and print “Interrupted!”.

D

It will enter a deadlock state and never resume.

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