DefaultNamedThreadFactory implements ThreadFactory { @Override public Thread newThread(Runnable r) { Thread t = new Thread(r, namePrefix + threadSeq.getAndIncrement()); t.setDaemon(true); return t; } DefaultNamedThreadFactory(String name); @Override Thread newThread(Runnable r);  }
@Test public void testNamedThread() throws Exception { Thread newThread = new DefaultNamedThreadFactory("DefaultNamedThreadFactoryTest").newThread(new Runnable() { @Override public void run() { } }); newThread.start(); assertNotNull(newThread.getName()); Assert.assertTrue(newThread.getName().contains("DefaultNamedThreadFactoryTest")); }