Java Program for extending Thread class

Write a Java program for extending thread class.



Source Code
public class ExtendThreadDemo extends Thread {

	public void run() {
		
		for(int i=1;i<=2;i++) {
			System.out.println("Thread Name : "+Thread.currentThread());
			System.out.println("Value of I = "+i);
			try {
				Thread.sleep(1);
			}
			catch (Exception ee){ }
		}
	}
	
	public static void main(String[] args) {
		
		System.out.println("In Main");
		ExtendThreadDemo t1=new ExtendThreadDemo();
		ExtendThreadDemo t2=new ExtendThreadDemo();
		t1.start();
		t2.start();
		System.out.println("Main Ends");
	}

}
Output
In Main
Main Ends
Thread Name : Thread[Thread-0,5,main]
Value of I = 1
Thread Name : Thread[Thread-1,5,main]
Value of I = 1
Thread Name : Thread[Thread-0,5,main]
Value of I = 2
Thread Name : Thread[Thread-1,5,main]
Value of I = 2