class Demo extends Thread { Demo(String name) { super(name); } public void run() { for(int i=0;i<50;i++) { System.out.println(Demo.currentThread().getName()+i); } } } public class ThreadDemo { public static void main(String[] args) { Demo d=new Demo("One--"); d.start(); for(int i=0;i<50;i++) { System.out.println("main run----"+i); } } }