@Test
public void testNewThread() throws Exception {

    Assert.assertTrue(endedThreads.isEmpty());
    WorkerThreadFactory factory = new WorkerThreadFactory("worker1");
    Thread thread1 = factory.newThread(new simpleCmd(1L));
    Thread thread2 = factory.newThread(new simpleCmd(2L));
    Assert.assertNotSame(thread1.getName(),thread2.getName());
    thread1.start();
    thread2.start();
    while(thread1.isAlive() || thread2.isAlive()){}
    Assert.assertEquals(2,endedThreads.size());
    Assert.assertEquals(3,endedThreads.get(0)+endedThreads.get(1));
}