All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.softicar.platform.common.core.thread.sleep.Sleep Maven / Gradle / Ivy

Go to download

The SoftiCAR Platform is a lightweight, Java-based library to create interactive business web applications.

There is a newer version: 50.0.0
Show newest version
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();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy