Java tutorial
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); } }