@Test
public void testNewScheduledThreadPool() throws InterruptedException {

  String reason = "(can be ignored in Tests) NewScheduledThreadPool";
  Thread.UncaughtExceptionHandler handler = new TestExceptionHandler(reason);
  int threadCount = 4;
  latch = new CountDownLatch(threadCount);
  ScheduledExecutorService exec = IoTDBThreadPoolFactory
      .newScheduledThreadPool(threadCount / 2, POOL_NAME, handler);
  for (int i = 0; i < threadCount; i++) {
    Runnable task = new TestThread(reason);
    ScheduledFuture<?> future = exec.scheduleAtFixedRate(task, 0, 1, TimeUnit.SECONDS);
    try {
      future.get();
    } catch (ExecutionException e) {
      assertEquals(reason, e.getCause().getMessage());
      count.addAndGet(1);
      latch.countDown();
    }
  }
  try {
    latch.await();
    assertEquals(count.get(), threadCount);
  } catch (InterruptedException E) {
    fail();
  }
}