public class MyThread1 extends Thread{
MyThread1(String name){
super(name);
}
public void run(){
for(int i=1; i<=15; i++){
System.out.println("I am "+getName()+i);
try{
Thread.sleep(1000);
}catch(Exception e){}
}
System.out.println("I Finished"+getName());
}
public static void main(String agr[]){
MyThread1 mt1=new MyThread1("Thread1");
mt1.start();
MyThread1 mt2=new MyThread1("Thread2");
mt2.start();
}
}
MyThread1(String name){
super(name);
}
public void run(){
for(int i=1; i<=15; i++){
System.out.println("I am "+getName()+i);
try{
Thread.sleep(1000);
}catch(Exception e){}
}
System.out.println("I Finished"+getName());
}
public static void main(String agr[]){
MyThread1 mt1=new MyThread1("Thread1");
mt1.start();
MyThread1 mt2=new MyThread1("Thread2");
mt2.start();
}
}