import java.util.Timer;
import java.util.TimerTask;
public class Show {
public static void main(String[] args) {
Timer timer = new Timer();
timer.schedule(new AnyTimerTask("1"),1000);
timer.schedule(new AnyTimerTask("2"),1000);
timer.schedule(new AnyTimerTask("3"),1000);
timer.schedule(new AnyTimerTask("4"),1000);
timer.schedule(new AnyTimerTask("5"),1000);
timer.schedule(new AnyTimerTask("6"),1000);
}
}
class AnyTimerTask extends TimerTask {
private String threadName;
public AnyTimerTask(String threadName) {
this.threadName = threadName;
}
public String getThreadName() {
return threadName;
}
@Override
public void run() {
System.out.println(" Thread.currentThread().getName() "
+ Thread.currentThread().getName() + " taskName " + threadName + "==="
+ System.nanoTime());
}
}