@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)); }
public Thread newThread(final Runnable command) { return new Thread(new Runnable() { public void run() { command.run(); } }, name + "-" + getThreadIDX()); }
WorkerThreadFactory implements ThreadFactory { public Thread newThread(final Runnable command) { return new Thread(new Runnable() { public void run() { command.run(); } }, name + "-" + getThreadIDX()); } }
WorkerThreadFactory implements ThreadFactory { public Thread newThread(final Runnable command) { return new Thread(new Runnable() { public void run() { command.run(); } }, name + "-" + getThreadIDX()); } WorkerThreadFactory(String commonName); }
WorkerThreadFactory implements ThreadFactory { public Thread newThread(final Runnable command) { return new Thread(new Runnable() { public void run() { command.run(); } }, name + "-" + getThreadIDX()); } WorkerThreadFactory(String commonName); Thread newThread(final Runnable command); }
WorkerThreadFactory implements ThreadFactory { public Thread newThread(final Runnable command) { return new Thread(new Runnable() { public void run() { command.run(); } }, name + "-" + getThreadIDX()); } WorkerThreadFactory(String commonName); Thread newThread(final Runnable command);  }