diff options
author | Gary Gregory <garydgregory@gmail.com> | 2021-08-13 16:42:51 -0400 |
---|---|---|
committer | Gary Gregory <garydgregory@gmail.com> | 2021-08-13 16:42:51 -0400 |
commit | 47d0046742cb747053c34374cf99a6469df2f370 (patch) | |
tree | 8af05224ae14944b28cdedc16e624fdc788401d7 /src/main/java/org/apache/commons/lang3/ThreadUtils.java | |
parent | f7fedbfc543f7592a4fe66f2a971e35d4090a62c (diff) | |
download | apache-commons-lang-47d0046742cb747053c34374cf99a6469df2f370.tar.gz |
Add and use ThreadUtils.sleepQuietly(long).
Diffstat (limited to 'src/main/java/org/apache/commons/lang3/ThreadUtils.java')
-rw-r--r-- | src/main/java/org/apache/commons/lang3/ThreadUtils.java | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/main/java/org/apache/commons/lang3/ThreadUtils.java b/src/main/java/org/apache/commons/lang3/ThreadUtils.java index 2a5f35d5c..beb4e7553 100644 --- a/src/main/java/org/apache/commons/lang3/ThreadUtils.java +++ b/src/main/java/org/apache/commons/lang3/ThreadUtils.java @@ -456,6 +456,23 @@ public class ThreadUtils { } /** + * Sleeps for the given amount of milliseconds while ignoring {@link InterruptedException}. + * <p> + * The sleep duration may be shorter than {@code millis} if we catch a {@link InterruptedException}. + * </p> + * + * @param millis the length of time to sleep in milliseconds + * @since 3.13.0 + */ + public static void sleepQuietly(final long millis) { + try { + sleep(Duration.ofMillis(millis)); + } catch (InterruptedException e) { + // be quiet. + } + } + + /** * <p> * ThreadUtils instances should NOT be constructed in standard programming. Instead, the class should be used as * {@code ThreadUtils.getAllThreads()} |