dujian0068 commented on code in PR #16266: URL: https://github.com/apache/kafka/pull/16266#discussion_r1635734496
########## clients/src/main/java/org/apache/kafka/common/utils/Time.java: ########## @@ -30,7 +30,40 @@ */ public interface Time { - Time SYSTEM = new SystemTime(); + // A time implementation that uses the system clock and sleep call. + // Use inline implementation to ensure that only one Time#SYSTEM exists in a program + Time SYSTEM = new Time() { + @Override + public long milliseconds() { + return System.currentTimeMillis(); + } + + @Override + public long nanoseconds() { + return System.nanoTime(); + } + + @Override + public void sleep(long ms) { + Utils.sleep(ms); + } + + @Override + public void waitObject(Object obj, Supplier<Boolean> condition, long deadlineMs) throws InterruptedException { Review Comment: Thank you very much for your reply, but I don't fully understand which method you want to refactor. The developer of `Time#waitObject()` seems to want to provide a unified synchronization method based on `Time`, but it doesn't seem to need to be refactored. But `ProducerMetadata#awaitUpdate` can remove the `synchronized` keyword -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org