@Test public void whenNewThreadIsAddedToSetTerminatedThreadsAreRemoved() { Thread thread = mock(Thread.class); when(thread.getState()).thenReturn(Thread.State.TERMINATED); set.addThread(thread); Thread thread2 = mock(Thread.class); set.addThread(thread2); assertEquals(1, getThreads().size()); assertEquals(thread2, getThreads().get(0)); }
public void addThread(Thread thread) { cleanUp(); threads.add(thread); }
ActiveThreadSet { public void addThread(Thread thread) { cleanUp(); threads.add(thread); } }
ActiveThreadSet { public void addThread(Thread thread) { cleanUp(); threads.add(thread); } ActiveThreadSet(); }
ActiveThreadSet { public void addThread(Thread thread) { cleanUp(); threads.add(thread); } ActiveThreadSet(); void addThread(Thread thread); void joinAll(); }
ActiveThreadSet { public void addThread(Thread thread) { cleanUp(); threads.add(thread); } ActiveThreadSet(); void addThread(Thread thread); void joinAll();  }