1234567891011121314151617181920212223242526272829303132 |
- import weather.*;
- import java.lang.Thread;
- import java.util.Timer;
- import java.util.TimerTask;
- public class Program {
- public static void main(String[] args) {
- Central central = new Central();
-
- String[] locations = { "vienna", "moscow", "tokyo", "bangkok", "kapstadt" };
-
- for (String location: locations) {
- central.addStation(location);
- }
-
- (new Timer()).scheduleAtFixedRate(new TimerTask() {
- long t0 = System.currentTimeMillis();
-
- @Override
- public void run() {
- if (System.currentTimeMillis() - t0 > 20 * 1000) {
- cancel();
- } else {
- central.measurementEvent();
- }
- }
- }, 0, 1000 * 5);
- }
- }
|