Package java.util

Examples of java.util.Timer.scheduleAtFixedRate()


      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

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

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

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

      // Ensure a Timer throws an NullPointerException if date is Null
      t = new Timer();
      testTask = new TimerTestTask();
      exception = false;
      try {
        t.scheduleAtFixedRate(testTask, null, 100);
      } catch (NullPointerException e) {
        exception = true;
      }
      assertTrue(
          "scheduleAtFixedRate with null date should throw NullPointerException",
View Full Code Here

      // Ensure proper sequence of exceptions
      t = new Timer();
      exception = false;
      d = new Date(-100);
      try {
        t.scheduleAtFixedRate(null, d, 10);
      } catch (NullPointerException e) {
      } catch (IllegalArgumentException e) {
        exception = true;
      }
      assertTrue(
View Full Code Here

      // Ensure proper sequence of exceptions
      t = new Timer();
      exception = false;
      try {
        t.scheduleAtFixedRate(null, null, -10);
      } catch (NullPointerException e) {
      } catch (IllegalArgumentException e) {
        exception = true;
      }
      assertTrue(
View Full Code Here

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

      t = new Timer();
      SlowThenFastTask slowThenFastTask = new SlowThenFastTask();
      d = new Date(System.currentTimeMillis() + 100);

      // at least 9 times even when asleep
      t.scheduleAtFixedRate(slowThenFastTask, d, 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.