What thread is interrupted?

Report a typo

What is the output of this snippet?

class Main {
    public static void main(String[] args) {
        Thread thread = new Thread(() -> {
            while(Thread.currentThread().isInterrupted()) {
                try {
                    Thread.sleep(2_000);
                } catch (InterruptedException e) {
                    Thread.currentThread().interrupt();
                }
            }
        });
        thread.start();
        thread.interrupt();
        System.out.println(Thread.currentThread().isInterrupted());
    }
}
Enter a short text
___

Create a free account to access the full topic