### Question:
MessageHandlerWorkerThreadFactory implements ThreadFactory { @Override public Thread newThread(final Runnable r) { final int seq = threadSequenceNumber.incrementAndGet(); return new Thread(r, "MessageHandler:" + queueName + ":" + seq); } MessageHandlerWorkerThreadFactory(final String queueName); @Override Thread newThread(final Runnable r);  }### Answer:
@Test public void shouldCreateNewThreads() throws Exception { final int numThreads = 5; final Runnable runnable = mock(Runnable.class); final List<Thread> expectedThreads = new LinkedList<>(); for (int seq = 1; seq <= numThreads; seq++) { final Thread expectedThread = mock(Thread.class); expectedThreads.add(expectedThread); whenNew(Thread.class).withArguments(runnable, "MessageHandler:" + queueName + ":" + seq) .thenReturn(expectedThread); } final List<Thread> actualThreads = new LinkedList<>(); for (int n = 0; n < numThreads; n++) { actualThreads.add(factory.newThread(runnable)); } assertEquals(expectedThreads, actualThreads); }