ThreadFactoryBuilder { public ThreadFactoryBuilder withUncaughtExceptionHandler( @Nullable UncaughtExceptionHandler uncaughtExceptionHandler) { this.uncaughtExceptionHandler = uncaughtExceptionHandler; 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 testWithUncaughtExceptionHandler() { UncaughtExceptionHandler handler = new UncaughtExceptionHandler() { @Override public void uncaughtException(Thread t, Throwable e) { } }; ThreadFactory threadFactory = ThreadFactoryBuilder.create().withUncaughtExceptionHandler(handler).build(); assertThat(threadFactory.newThread(TEST_RUNNABLE).getUncaughtExceptionHandler(), is(handler)); }