NamedInternalThreadFactory extends NamedThreadFactory { @Override public Thread newThread(Runnable runnable) { String name = mPrefix + mThreadNum.getAndIncrement(); InternalThread ret = new InternalThread(mGroup, runnable, name, 0); ret.setDaemon(mDaemon); return ret; } NamedInternalThreadFactory();  NamedInternalThreadFactory(String prefix);  NamedInternalThreadFactory(String prefix, boolean daemon); @Override Thread newThread(Runnable runnable);  }
@Test public void newThread() throws Exception { NamedInternalThreadFactory namedInternalThreadFactory = new NamedInternalThreadFactory(); Thread t = namedInternalThreadFactory.newThread(new Runnable() { @Override public void run() { } }); Assert.assertTrue("thread is not InternalThread", t.getClass().equals(InternalThread.class)); }
@Test public void newThread() throws Exception { NamedInternalThreadFactory namedInternalThreadFactory = new NamedInternalThreadFactory(); Thread t = namedInternalThreadFactory.newThread(new Runnable() { @Override public void run() { } }); Assertions.assertEquals(t.getClass(), InternalThread.class, "thread is not InternalThread"); }