### Question:
Threads { public static ThreadFactory newThreadFactory(final String groupName) { return new ThreadFactory() { @SuppressWarnings("PMD.AvoidThreadGroup") final ThreadGroup initialization = new ThreadGroup(groupName); final AtomicInteger threadNumber = new AtomicInteger(-1); @Override public Thread newThread(final Runnable task) { final Thread thread = new Thread(initialization, task); thread.setName(groupName + "-" + threadNumber.incrementAndGet()); final Logger log = LoggerFactory.getLogger(task.getClass()); thread.setUncaughtExceptionHandler(new Logging(log)); return thread; } }; } private  Threads(); static ThreadFactory newThreadFactory(final String groupName);  }### Answer:
@Test public void shouldCreateThreadFactories() { final ThreadFactory newThreadFactory = Threads.newThreadFactory("test name"); final Thread thread = newThreadFactory.newThread(System::gc); assertThat(thread.getThreadGroup().getName()).isEqualTo("test name"); assertThat(thread.getName()).isEqualTo("test name-0"); }