package itcast.thread;
import java.util.Timer;
import java.util.TimerTask;
public class TraditionalTimer {
public static void main(String[] args) {
TraditionalTimer t = new TraditionalTimer();
t.init();
while(true){
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
long l = System.currentTimeMillis();
System.out.println(l/1000%60);
}
}
private void init(){
new Timer().schedule(new TaskA(), 2000);
}
public class TaskA extends TimerTask{
public void run() {
System.out.println("bombing");
new Timer().schedule(new TaskB(), 4000);
}
}
public class TaskB extends TimerTask{
public void run(){
System.out.println("bombing");
new Timer().schedule(new TaskA(), 2000);
}
}
}