ThreadFactoryBuilder { public ThreadFactoryBuilder withDaemonThreads(boolean daemonThreads) { this.daemonThreads = daemonThreads; return this; } private  ThreadFactoryBuilder(); static ThreadFactoryBuilder create(); ThreadFactoryBuilder withWrappedThreadFactory(@Nullable ThreadFactory wrappedThreadFactory); ThreadFactoryBuilder withName(@Nullable String name); ThreadFactoryBuilder withNamePrefix(@Nullable String namePrefix); ThreadFactoryBuilder withDaemonThreads(boolean daemonThreads); ThreadFactoryBuilder withUncaughtExceptionHandler(
            @Nullable UncaughtExceptionHandler uncaughtExceptionHandler); ThreadFactoryBuilder withPriority(@Nullable Integer priority); ThreadFactory build();  }
@Test public void testWithDaemonThreads() { ThreadFactory threadFactory = ThreadFactoryBuilder.create().withDaemonThreads(true).build(); assertThat(threadFactory.newThread(TEST_RUNNABLE).isDaemon(), is(true)); threadFactory = ThreadFactoryBuilder.create().withDaemonThreads(false).build(); assertThat(threadFactory.newThread(TEST_RUNNABLE).isDaemon(), is(false)); }