com.softicar.platform.common.core.thread.sleep.Sleep Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of platform-common Show documentation
Show all versions of platform-common Show documentation
The SoftiCAR Platform is a lightweight, Java-based library to create interactive business web applications.
package com.softicar.platform.common.core.thread.sleep;
import com.softicar.platform.common.core.thread.sleeper.CurrentSleeper;
import java.time.Duration;
import java.time.Instant;
import java.util.Objects;
/**
* Facade for {@link Thread} sleeping.
*
* @author Oliver Richers
*/
public class Sleep {
/**
* Sleeps for the given amount of milliseconds.
*
* @param millis
* the milliseconds to sleep
*/
public static void sleep(long millis) {
CurrentSleeper.get().sleep(millis);
}
/**
* Sleeps for the given {@link Duration}.
*
* @param duration
* the {@link Duration} to sleep (never null)
*/
public static void sleep(Duration duration) {
sleep(Objects.requireNonNull(duration).toMillis());
}
/**
* Sleeps until the given target {@link Instant}.
*
* @param target
* the target {@link Instant} (never null)
*/
public static void sleepUntil(Instant target) {
new SleepUntil(target).sleep();
}
}