### Question:
SimpleTimer { public ScheduledFuture<?> schedule(Runnable task, long delay) { return executor.schedule(task, delay, TimeUnit.MILLISECONDS); } private  SimpleTimer(int threadPoolSize); static synchronized SimpleTimer getInstance(int threadPoolSize); static synchronized SimpleTimer getInstance(AccumuloConfiguration conf); ScheduledFuture<?> schedule(Runnable task, long delay); ScheduledFuture<?> schedule(Runnable task, long delay, long period);  }### Answer:
@Test public void testOneTimeSchedule() throws InterruptedException { AtomicInteger i = new AtomicInteger(); Incrementer r = new Incrementer(i); t.schedule(r, DELAY); Thread.sleep(DELAY + PAD); assertEquals(1, i.get()); r.cancel(); }
@Test public void testFixedDelaySchedule() throws InterruptedException { AtomicInteger i = new AtomicInteger(); Incrementer r = new Incrementer(i); t.schedule(r, DELAY, PERIOD); Thread.sleep(DELAY + (2 * PERIOD) + PAD); assertEquals(3, i.get()); r.cancel(); }
@Test public void testFailure() throws InterruptedException { Thrower r = new Thrower(); t.schedule(r, DELAY); Thread.sleep(DELAY + PAD); assertTrue(r.wasRun); }