mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2026-08-06 19:21:02 -06:00
55 lines
No EOL
1.1 KiB
Java
55 lines
No EOL
1.1 KiB
Java
package ms.system.util;
|
|
|
|
import java.util.concurrent.Executors;
|
|
import java.util.concurrent.ScheduledExecutorService;
|
|
|
|
/**
|
|
* A class holding methods to execute tasks.
|
|
* @author Emperor
|
|
*
|
|
*/
|
|
public final class TaskExecutor {
|
|
|
|
/**
|
|
* The executor to use.
|
|
*/
|
|
private static final ScheduledExecutorService EXECUTOR = Executors.newSingleThreadScheduledExecutor();
|
|
|
|
/**
|
|
* The SQL task executor.
|
|
*/
|
|
private static final ScheduledExecutorService SQL_EXECUTOR = Executors.newSingleThreadScheduledExecutor();
|
|
|
|
/**
|
|
* Constructs a new {@code TaskExecutor} {@code Object}.
|
|
*/
|
|
private TaskExecutor() {
|
|
/*
|
|
* empty.
|
|
*/
|
|
}
|
|
|
|
/**
|
|
* Executes an SQL handling task.
|
|
* @param task The task.
|
|
*/
|
|
public static void executeSQL(Runnable task) {
|
|
SQL_EXECUTOR.execute(task);
|
|
}
|
|
|
|
/**
|
|
* Executes the task.
|
|
* @param task The task to execute.
|
|
*/
|
|
public static void execute(Runnable task) {
|
|
EXECUTOR.execute(task);
|
|
}
|
|
|
|
/**
|
|
* Gets the executor.
|
|
* @return The executor.
|
|
*/
|
|
public static ScheduledExecutorService getExecutor() {
|
|
return EXECUTOR;
|
|
}
|
|
} |