2022-06-10 02:55:46 +02:00
|
|
|
package com.falsepattern.lib.util;
|
|
|
|
|
|
|
|
|
|
import com.falsepattern.lib.internal.Tags;
|
|
|
|
|
|
|
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
|
|
import java.util.concurrent.Executors;
|
|
|
|
|
|
2022-06-10 03:00:23 +02:00
|
|
|
/**
|
|
|
|
|
* Asynchronous utilities. Notice: you should not abuse this for anything performance-sensitive.
|
|
|
|
|
* The asynchronous worker exists primarily to run code independently of the main thread during loading.
|
|
|
|
|
* You must make sure to solve any potential deadlocks yourself!
|
2022-06-19 22:42:34 +02:00
|
|
|
*
|
|
|
|
|
* //Deprecated since 0.9.0, removal in 0.10+: Use java-provided async tools instead. CompletableFuture is a nice one.
|
2022-06-10 03:00:23 +02:00
|
|
|
*/
|
2022-06-19 22:42:34 +02:00
|
|
|
@Deprecated
|
2022-06-12 11:56:22 +02:00
|
|
|
public class AsyncUtil {
|
2022-06-10 02:55:46 +02:00
|
|
|
public static final ExecutorService asyncWorker = Executors.newSingleThreadExecutor((runnable) -> {
|
|
|
|
|
Thread thread = new Thread(runnable);
|
|
|
|
|
thread.setDaemon(true);
|
|
|
|
|
thread.setName(Tags.MODNAME + " Async Worker");
|
|
|
|
|
return thread;
|
|
|
|
|
});
|
|
|
|
|
}
|