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