Package java.util

Examples of java.util.Timer.scheduleAtFixedRate()


      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

                listenerThread.start();

                Broadcaster broadcaster = new Broadcaster();

                Timer timer = new Timer("MulticastDiscovery: Broadcaster", true);
                timer.scheduleAtFixedRate(broadcaster, 0, heartRate);
            }
    }

    private void newSocket() throws IOException {
        InetAddress inetAddress = InetAddress.getByName(host);
View Full Code Here

        };
       
        Timer result=new Timer(endpoint.getTimerName(),endpoint.isDaemon());
        if(endpoint.isFixedRate()){
            if(endpoint.getTime()!=null){
                result.scheduleAtFixedRate(task,endpoint.getTime(),endpoint.getPeriod());
            }else{
                result.scheduleAtFixedRate(task,endpoint.getDelay(),endpoint.getPeriod());
            }
        }else{
            if(endpoint.getTime()!=null){
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.