Created
January 21, 2020 06:47
-
-
Save fuxingloh/3108f4614f0ce1ffcf4c567166812f24 to your computer and use it in GitHub Desktop.
Thread.sleep with checked InterruptedException wrapped in unchecked.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package dev.fuxing.utils; | |
import java.time.Duration; | |
/** | |
* Created by: Fuxing | |
* Date: 20/8/18 | |
* Time: 6:43 PM | |
*/ | |
public final class SleepUtils { | |
private SleepUtils() { /**/ } | |
/** | |
* @param duration duration to sleep | |
*/ | |
public static void sleep(Duration duration) { | |
sleep(duration.toMillis()); | |
} | |
/** | |
* @param millis to sleep | |
*/ | |
public static void sleep(long millis) { | |
try { | |
Thread.sleep(millis); | |
} catch (InterruptedException e) { | |
throw new RuntimeException(e); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment