Bat/src/main/java/cc/fascinated/bat/common/TimerUtils.java
2024-06-23 21:37:24 +01:00

28 lines
650 B
Java

package cc.fascinated.bat.common;
import lombok.experimental.UtilityClass;
import java.util.Timer;
import java.util.TimerTask;
/**
* @author Fascinated (fascinated7)
*/
@UtilityClass
public class TimerUtils {
/**
* Runs a repeating task on a schedule
*
* @param runnable the task to run
* @param delay the delay before the task runs
*/
public static void scheduleRepeating(Runnable runnable, long delay, long period) {
new Timer().scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
runnable.run();
}
}, delay, period);
}
}