Timer { public boolean isExpiredResetOnTrue() { boolean expired = System.nanoTime() - this.start >= this.periodNanos; if(expired) { this.start = System.nanoTime(); } return expired; } Timer(long delay, long period, TimeUnit timeUnit); long period(); long delay(); TimeUnit getTimeUnit(); boolean isExpiredResetOnTrue();  }
@Test public void testReset() throws InterruptedException { Timer t = new Timer(0, 2, TimeUnit.SECONDS); Thread.sleep(1000); assertFalse(t.isExpiredResetOnTrue()); Thread.sleep(1000); assertTrue(t.isExpiredResetOnTrue()); }