import java.util.Date;
public class TimePrinter extends Thread{
int sleepTime;
String name;
int counter;
public TimePrinter(int x,String n)
{
sleepTime=x;
name=n;
counter=0;
}
public void run()
{
while(counter<20)
{
try{
counter++;
System.out.println(name+":"+new Date(System.currentTimeMillis()));
Thread.sleep(sleepTime);
}
catch(InterruptedException e)
{
System.out.println(e);
}
}
}
public static void main(String args[])
{
TimePrinter tp1=new TimePrinter(1000,"Fast Thread");
tp1.start();
TimePrinter tp2=new TimePrinter(3000,"Slow Thread");
tp2.start();
}
}