What will be the output of this program?

Last Updated :
Discuss
Comments

What will be the output of this program?

Java
class TestThread extends Thread {
    public void run() {
        try {
            Thread.sleep(1000);
            System.out.println("Thread Running");
        } catch (InterruptedException e) {
            System.out.println("Interrupted");
        }
    }

    public static void main(String[] args) {
        TestThread t = new TestThread();
        t.start();
        t.interrupt();
    }
}


Thread Running

Interrupted

No Output

Both A and B, depending on timing

Share your thoughts in the comments