1 code #
package test01; public class ThreadTest { /** * @param args */ public static void main(String[] args) throws Exception { Mythread th = new ThreadTest().new Mythread(); th.start(); System.out.println("STARTED"); th.join(); System.out.println("FINISHED"); } class Mythread extends Thread { public void run() { for(int i=0; i<3; i++){ System.out.println(i); try{ Thread.sleep(1000); } catch(InterruptedException ie){ ie.printStackTrace(); } } } } }