Package java.util

Examples of java.util.Timer.cancel()


    Timer t = null;
    try {
      // Ensure a task throws an IllegalStateException after cancelled
      t = new Timer();
      TimerTestTask testTask = new TimerTestTask();
      t.cancel();
      boolean exception = false;
      try {
        t.schedule(testTask, 100, 200);
      } catch (IllegalStateException e) {
        exception = true;
View Full Code Here


        } catch (InterruptedException e) {
        }
      }
      assertEquals("TimerTask.run() method not called after 200ms",
          1, testTask.wasRun());
      t.cancel();
      synchronized (sync) {
        try {
          sync.wait(500);
        } catch (InterruptedException e) {
        }
View Full Code Here

        } catch (InterruptedException e) {
        }
      }
      assertEquals("TimerTask.run() method not called after 200ms",
          1, testTask.wasRun());
      t.cancel();
      t.cancel();
      t.cancel();
      synchronized (sync) {
        try {
          sync.wait(500);
View Full Code Here

        }
      }
      assertEquals("TimerTask.run() method not called after 200ms",
          1, testTask.wasRun());
      t.cancel();
      t.cancel();
      t.cancel();
      synchronized (sync) {
        try {
          sync.wait(500);
        } catch (InterruptedException e) {
View Full Code Here

      }
      assertEquals("TimerTask.run() method not called after 200ms",
          1, testTask.wasRun());
      t.cancel();
      t.cancel();
      t.cancel();
      synchronized (sync) {
        try {
          sync.wait(500);
        } catch (InterruptedException e) {
        }
View Full Code Here

        } catch (InterruptedException e) {
        }
      }
      assertTrue("TimerTask.run() method should be called 5 times not "
          + testTask.wasRun(), testTask.wasRun() == 5);
      t.cancel();
      try {
        Thread.sleep(200);
      } catch (InterruptedException e) {
      }
    } finally {
View Full Code Here

        Thread.sleep(200);
      } catch (InterruptedException e) {
      }
    } finally {
      if (t != null)
        t.cancel();
    }

  }

  /**
 
View Full Code Here

            assertTrue(t.purge() <= 50);
            assertEquals(0, t.purge());
        } finally {
            if (t != null) {
                t.cancel();
            }
        }
    }

    /**
 
View Full Code Here

    try {
      // Ensure a Timer throws an IllegalStateException after cancelled
      t = new Timer();
      TimerTestTask testTask = new TimerTestTask();
      Date d = new Date(System.currentTimeMillis() + 100);
      t.cancel();
      boolean exception = false;
      try {
        t.schedule(testTask, d);
      } catch (IllegalStateException e) {
        exception = true;
View Full Code Here

        exception = true;
      }
      assertTrue(
          "Scheduling a task after cancelling it should throw exception",
          exception);
      t.cancel();

      // Ensure a Timer throws an IllegalArgumentException if delay is
      // negative
      t = new Timer();
      testTask = new TimerTestTask();
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.