// and then shutting down the connection.
// this is to avoid yanking away the connection from the consumer runnables
stopLatch = new CountDownLatch(streams.size());
for (final KafkaStream<byte[], byte[]> stream : streams) {
executor.submit(new Runnable() {
public void run() {
final ConsumerIterator<byte[], byte[]> consumerIterator = stream.iterator();
// we have to use hasNext() here instead foreach, because next() marks the message as processed immediately
//noinspection WhileLoopReplaceableByForEach