@Test
  public void testReschedule() throws Exception {
    ScheduledExecutorService ex = Executors.newScheduledThreadPool(1);
    OneTaskOnlyExecutor decorator = new OneTaskOnlyExecutor(ex, null);

    final CountDownLatch taskRunning = new CountDownLatch(1);
    final CountDownLatch continueTask = new CountDownLatch(1);
    final AtomicInteger counter = new AtomicInteger();

    Callable waitForLatch = () -> {
      taskRunning.countDown();
      continueTask.await();
      counter.incrementAndGet();
      return null;
    };

    Runnable increment = counter::incrementAndGet;

    decorator.schedule(waitForLatch, 0, TimeUnit.SECONDS);
    taskRunning.await();
    decorator.schedule(increment, 0, TimeUnit.SECONDS);

    assertEquals(0, counter.get());
    continueTask.countDown();

    ex.shutdown();
    ex.awaitTermination(60, TimeUnit.SECONDS);
    assertEquals(2, counter.get());
  }
Test to make sure we reschedule the task for execution if it has already in progress.
geode-core/src/test/java/org/apache/geode/internal/OneTaskOnlyDecoratorJUnitTest.java