package program;
public class Program {
javax.swing.Timer dynTimer;
public long startTime;
public boolean running = true;
public static void main(String[] args) {
Program p = new Program();
p.init();
p.start();
}
private void init() {
System.out.println("> Инициализация");
dynTimer = new javax.swing.Timer(100, (java.awt.event.ActionEvent e) -> {
update(e.getWhen());
});
}
private void start() {
System.out.println("> Запуск");
dynTimer.start();
startTime = new java.util.Date().getTime();
while (running) {
try {
Thread.sleep(100);
System.out.println("::: " + running);
} catch (InterruptedException ie) {
System.out.println("Child thread interrupted! " + ie);
}
}
}
private void update(long when) {
System.out.println("Событие: " + (startTime + 1000) + " : " + when + " : " + running);
if(startTime + 1000 < when) running = false;
}
}