public static ExecutorService newScalingThreadPool(int min, int max, long keepAliveTime) {
    ScalingQueue<Runnable> queue = new ScalingQueue<>();
    ThreadPoolExecutor executor = new ScalingThreadPoolExecutor(min, max, keepAliveTime, TimeUnit.MILLISECONDS, queue);
    executor.setRejectedExecutionHandler(new ForceQueuePolicy());
    return executor;
  }
@Test
  public void testScaleDownAfterDelay() {
    ThreadPoolExecutor executorService = (ThreadPoolExecutor) ScalingThreadPoolExecutor.newScalingThreadPool(0, 5, 500);
    for (int i = 0; i < 2; i++) {
      executorService.submit(getSleepingRunnable());
    }
    TestUtils.waitForCondition(aVoid -> executorService.getPoolSize() == 0, 2000,
        "Timed out waiting for thread pool to scale down");
  }