private void handleEvents() {
            while (!shuttingDown) {
                // We use a single meter for aggregate idle percentage for the thread pool.
                // Since meter is calculated as total_recorded_value / time_window and
                // time_window is independent of the number of threads, each recorded idle
                // time should be discounted by # threads.

                long idleStartTimeMs = time.milliseconds();
                CoordinatorEvent event = accumulator.poll(POLL_TIMEOUT_MS, TimeUnit.MILLISECONDS);
                long idleEndTimeMs = time.milliseconds();
                long idleTimeMs = idleEndTimeMs - idleStartTimeMs;
                metrics.recordThreadIdleTime(idleTimeMs / threads.size());
                if (event != null) {
                    try {
                        log.debug("Executing event: {}.", event);
                        long dequeuedTimeMs = time.milliseconds();
                        metrics.recordEventQueueTime(dequeuedTimeMs - event.createdTimeMs());
                        event.run();
                        metrics.recordEventQueueProcessingTime(time.milliseconds() - dequeuedTimeMs);
                    } catch (Throwable t) {
                        log.error("Failed to run event {} due to: {}.", event, t.getMessage(), t);
                        event.complete(t);
                    } finally {
                        accumulator.done(event);
                    }
                }
            }
        }
The event processor thread. The thread pulls events from the
accumulator and runs them.
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/runtime/MultiThreadedEventProcessor.java