Is a thread interrupted

Report a typo

What is an output of this code snippet?

class Main {
    public static void main(String[] args) {
        Thread thread = new Thread(() -> {
            if (!Thread.interrupted()) {
                System.out.println(Thread.interrupted());
            } else {
                while (true) {
                    if (!Thread.interrupted()) {
                        System.out.println(Thread.interrupted());
                        break;
                    }
                }
            }
        });
        thread.start();
        thread.interrupt();
    }
}
Enter a short text
___

Create a free account to access the full topic