protected int processStreamThread(final Consumer<StreamThread> consumer) {
        final List<StreamThread> copy = new ArrayList<>(threads);
        for (final StreamThread thread : copy) consumer.accept(thread);

        return copy.size();
    }
handle each stream thread in a snapshot of threads.
noted: iteration over SynchronizedList is not thread safe so it must be manually synchronized. However, we may
require other locks when looping threads and it could cause deadlock. Hence, we create a copy to avoid holding
threads lock when looping threads.
@param consumer handler
streams/src/main/java/org/apache/kafka/streams/KafkaStreams.java