@Test public void testThreadedStreamConsumer() throws Exception { final CountDownLatch countDown = new CountDownLatch( 5_000_000 ); EventHandler<Event> handler = new EventHandler<Event>() { @Override public void handleEvent( @Nonnull Event event ) { countDown.countDown(); } }; ThreadedStreamConsumer streamConsumer = new ThreadedStreamConsumer( handler ); SECONDS.sleep( 1 ); System.gc(); SECONDS.sleep( 2 ); long t1 = System.currentTimeMillis(); Event event = new StandardStreamOutWithNewLineEvent( NORMAL_RUN, "" ); for ( int i = 0; i < 5_000_000; i++ ) { streamConsumer.handleEvent( event ); } assertThat( countDown.await( 3L, SECONDS ) ) .isTrue(); long t2 = System.currentTimeMillis(); System.out.println( ( t2 - t1 ) + " millis in testThreadedStreamConsumer()" ); streamConsumer.close(); }
public ThreadedStreamConsumer( EventHandler<Event> target ) { pumper = new Pumper( target ); Thread thread = newDaemonThread( pumper, "ThreadedStreamConsumer" ); thread.start(); }
ThreadedStreamConsumer implements EventHandler<Event>, Closeable { public ThreadedStreamConsumer( EventHandler<Event> target ) { pumper = new Pumper( target ); Thread thread = newDaemonThread( pumper, "ThreadedStreamConsumer" ); thread.start(); } }
ThreadedStreamConsumer implements EventHandler<Event>, Closeable { public ThreadedStreamConsumer( EventHandler<Event> target ) { pumper = new Pumper( target ); Thread thread = newDaemonThread( pumper, "ThreadedStreamConsumer" ); thread.start(); } ThreadedStreamConsumer( EventHandler<Event> target ); }
ThreadedStreamConsumer implements EventHandler<Event>, Closeable { public ThreadedStreamConsumer( EventHandler<Event> target ) { pumper = new Pumper( target ); Thread thread = newDaemonThread( pumper, "ThreadedStreamConsumer" ); thread.start(); } ThreadedStreamConsumer( EventHandler<Event> target ); @Override void handleEvent( @Nonnull Event event ); @Override void close(); }
ThreadedStreamConsumer implements EventHandler<Event>, Closeable { public ThreadedStreamConsumer( EventHandler<Event> target ) { pumper = new Pumper( target ); Thread thread = newDaemonThread( pumper, "ThreadedStreamConsumer" ); thread.start(); } ThreadedStreamConsumer( EventHandler<Event> target ); @Override void handleEvent( @Nonnull Event event ); @Override void close();  }