### Question:
LoopGenerator extends BaseGenerator<E> { public void stop() { if (wrappedGenerator != null && wrappedGenerator instanceof LoopGenerator<?>) { ((LoopGenerator<?>) wrappedGenerator).stop(); } stopped = true; } LoopGenerator();  LoopGenerator(Generator<? extends E> generator); void stop(); boolean isStopped();  }### Answer:
@Test public void testStop() { final StringBuilder result = new StringBuilder(); simpleGenerator.run(new Procedure<Integer>() { int i = 0; public void run(Integer obj) { result.append(obj); if (i++ > 1) { simpleGenerator.stop(); } } }); assertEquals("012", result.toString()); }