ExecutorUtils { public static ScheduledExecutorService buildSingleThreadScheduledExecutorService(String name) { final ThreadFactory threadFactory = ExecutorUtils.getNamedThreadFactory(name); final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(threadFactory); ExecutorUtils.addDelayedShutdownHook(name, executor); return executor; } private  ExecutorUtils(); static ExecutorService buildThreadPoolExecutorService(String name); static ScheduledExecutorService buildSingleThreadScheduledExecutorService(String name);  }
@Test public void testBuildSingleThreadScheduledExecutorService() throws Exception { final ExecutorService service = ExecutorUtils.buildSingleThreadScheduledExecutorService(THREAD_FACTORY_NAME); final Future<String> future = service.submit(new ThreadNameCallable()); assertEquals(FIRST_THREAD_NAME, future.get()); }