ThreadPoolUtil { public static ThreadFactory buildThreadFactory(@NotNull String threadNamePrefix) { return new ThreadFactoryBuilder().setNameFormat(threadNamePrefix + "-%d").build(); }  static boolean gracefulShutdown(@Nullable ExecutorService threadPool, int shutdownTimeoutMills); static boolean gracefulShutdown(@Nullable ExecutorService threadPool, int shutdownTimeout,
			TimeUnit timeUnit); static ThreadFactory buildThreadFactory(@NotNull String threadNamePrefix); static ThreadFactory buildThreadFactory(@NotNull String threadNamePrefix, @NotNull boolean daemon); static Runnable safeRunnable(@NotNull Runnable runnable);  }
@Test public void buildThreadFactory() { Runnable testRunnable = new Runnable() { @Override public void run() { } }; ThreadFactory threadFactory = ThreadPoolUtil.buildThreadFactory("example"); Thread thread = threadFactory.newThread(testRunnable); assertThat(thread.getName()).isEqualTo("example-0"); assertThat(thread.isDaemon()).isFalse(); threadFactory = ThreadPoolUtil.buildThreadFactory("example", true); Thread thread2 = threadFactory.newThread(testRunnable); assertThat(thread.getName()).isEqualTo("example-0"); assertThat(thread2.isDaemon()).isTrue(); }