Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

public class Main {
    public static void main(String[] args) {
        System.out.println("#1:" + Thread.interrupted());

        // Now interrupt the main thread
        Thread.currentThread().interrupt();

        // Check if it has been interrupted
        System.out.println("#2:" + Thread.interrupted());

        // Check again if it has been interrupted
        System.out.println("#3:" + Thread.interrupted());
    }
}