Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

public class Main extends Thread {
    public Main(String name) {
        super(name);
    }

    @Override
    public void run() {
        Thread t = Thread.currentThread();
        String threadName = t.getName();
        System.out.println("Inside run() method:  " + threadName);
    }

    public static void main(String[] args) {
        Main ct1 = new Main("First Thread");
        Main ct2 = new Main("Second Thread");
        ct1.start();
        ct2.start();

        Thread t = Thread.currentThread();
        String threadName = t.getName();
        System.out.println("Inside  main() method:  " + threadName);
    }
}