@Override
        public int compareTo(Delayed o) {
            long diff = getDelay(TimeUnit.NANOSECONDS) - o.getDelay(TimeUnit.NANOSECONDS);
            if (diff < 0)
                return -1;
            else if (diff > 0)
                return 1;
            else
                return 0;
        }
A scheduler based on java.util.concurrent.ScheduledThreadPoolExecutor
<br>
It has a pool of kafka-scheduler- threads that do the actual work.
server-common/src/main/java/org/apache/kafka/server/util/KafkaScheduler.java