class FourThreads extends Thread
{
FourThreads(String n)
{
super(n);
System.out.println("Thread is :"+getName());
}
public void run()
{
try
{
for(int i=1;i<=3;i++)
{
System.out.println(getName()+":"+i);
sleep(200);
}
}
catch(InterruptedException e)
{
System.out.println(getName()+"is Interrupted");
}
}
}
class FourThreadsJavaExample
{
public static void main(String args[])
{
FourThreads t1=new FourThreads("First Thread");
FourThreads t2=new FourThreads("Second Thread");
FourThreads t3=new FourThreads("Third Thread");
FourThreads t4=new FourThreads("Fourth Thread");
t1.start();
t2.start();
t3.start();
t4.start();
}
}