This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-io.git
commit fb41f50162ee5da4b515fe5dbc786de5fe721722 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Wed May 3 07:44:10 2023 -0400 Javadoc --- src/main/java/org/apache/commons/io/ThreadUtils.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/apache/commons/io/ThreadUtils.java b/src/main/java/org/apache/commons/io/ThreadUtils.java index 2fd661c1..8e495227 100644 --- a/src/main/java/org/apache/commons/io/ThreadUtils.java +++ b/src/main/java/org/apache/commons/io/ThreadUtils.java @@ -26,22 +26,23 @@ import java.time.Instant; */ public class ThreadUtils { - static int getNanosOfMilli(final Duration duration) { + private static int getNanosOfMilli(final Duration duration) { return duration.getNano() % 1_000_000; } /** * Sleeps for a guaranteed minimum duration unless interrupted. - * - * This method exists because Thread.sleep(100) can sleep for 0, 70, 100 or 200ms or anything else it deems appropriate. - * Read {@link Thread#sleep(long, int)}} for further interesting details. - * - * TODO The above needs confirmation now that we've been on Java 8 for a while. + * <p> + * This method exists because Thread.sleep(100) can sleep for 0, 70, 100 or 200ms or anything else it deems appropriate. Read + * {@link Thread#sleep(long, int)}} for further interesting details. + * </p> * * @param duration the sleep duration. - * @throws InterruptedException if interrupted. + * @throws InterruptedException if interrupted + * @see Thread#sleep(long, int) */ public static void sleep(final Duration duration) throws InterruptedException { + // Using this method avoids depending on the vagaries of the precision and accuracy of system timers and schedulers. final Instant finishInstant = Instant.now().plus(duration); Duration remainingDuration = duration; do {