Package java.util

Examples of java.util.Timer.scheduleAtFixedRate()


                    snapshotList.removeFirst();
                }
            }
        }, 1000, 1000);

        timer.scheduleAtFixedRate(new TimerTask() {
            private void printStats() {
                if (snapshotList.size() >= 10) {
                    Long[] begin = snapshotList.getFirst();
                    Long[] end = snapshotList.getLast();
View Full Code Here


            }

            Timer timer = ejbContainerUtilImpl.getTimer();
            if (RELATIVE_TIME_CHECK_MODE) {
                refreshTask = new CurrentTimeRefreshTask ();
                timer.scheduleAtFixedRate(refreshTask, timerFrequency*1000L, timerFrequency*1000L);
            } else {
                refreshTask = new RefreshTask();
                timer.scheduleAtFixedRate(refreshTask, refreshPeriodInMillis,
                                      refreshPeriodInMillis);
            }
View Full Code Here

            if (RELATIVE_TIME_CHECK_MODE) {
                refreshTask = new CurrentTimeRefreshTask ();
                timer.scheduleAtFixedRate(refreshTask, timerFrequency*1000L, timerFrequency*1000L);
            } else {
                refreshTask = new RefreshTask();
                timer.scheduleAtFixedRate(refreshTask, refreshPeriodInMillis,
                                      refreshPeriodInMillis);
            }
        } else {
            refreshPeriodInMillis = 0;
        }
View Full Code Here

            final Send message = new Send(address, multicast, send);

            if (rate > 0) {
                final Timer timer = new Timer("Multicast Send", true);
                timer.scheduleAtFixedRate(message, 0, rate);
            } else {
                message.run();
                message.close();
            }
        }
View Full Code Here

        setResizable(false);
        setSize(300,125);
        show();
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        Timer displayTimer = new Timer();
        displayTimer.scheduleAtFixedRate(new TimerTask() {
            public void run() {
                display.setText(DISPLAY_PREFIX + stopWatch.getDisplay()
                    + DISPLAY_SUFFIX);
                state.setText(STATE_PREFIX + stopWatch.getCurrentState()
                    + STATE_SUFFIX);
View Full Code Here

      t = new Timer();
      TimerTestTask testTask = new TimerTestTask();
      t.cancel();
      boolean exception = false;
      try {
        t.scheduleAtFixedRate(testTask, 100, 100);
      } catch (IllegalStateException e) {
        exception = true;
      }
      assertTrue(
          "scheduleAtFixedRate after Timer.cancel() should throw exception",
View Full Code Here

      // negative
      t = new Timer();
      testTask = new TimerTestTask();
      exception = false;
      try {
        t.scheduleAtFixedRate(testTask, -100, 100);
      } catch (IllegalArgumentException e) {
        exception = true;
      }
      assertTrue(
          "scheduleAtFixedRate with negative delay should throw IllegalArgumentException",
View Full Code Here

      // negative
      t = new Timer();
      testTask = new TimerTestTask();
      exception = false;
      try {
        t.scheduleAtFixedRate(testTask, 100, -100);
      } catch (IllegalArgumentException e) {
        exception = true;
      }
      assertTrue(
          "scheduleAtFixedRate with negative period should throw IllegalArgumentException",
View Full Code Here

      t.cancel();

      // Ensure a task is run at least twice
      t = new Timer();
      testTask = new TimerTestTask();
      t.scheduleAtFixedRate(testTask, 100, 100);
      try {
        Thread.sleep(400);
      } catch (InterruptedException e) {
      }
      assertTrue(
View Full Code Here

      // Ensure multiple tasks are run
      t = new Timer();
      SlowThenFastTask slowThenFastTask = new SlowThenFastTask();

      // at least 9 times even when asleep
      t.scheduleAtFixedRate(slowThenFastTask, 100, 100);
      try {
        Thread.sleep(1000);
      } catch (InterruptedException e) {
      }
      long lastDelta = slowThenFastTask.lastDelta();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.