some more utilities

This commit is contained in:
FalsePattern committed 2022-06-12 11:56:22 +02:00
1 parent ac55a661a9
commit 3401ca837a
7 files changed
+74 -22

No files matched your search

@@ -0,0 +1,22 @@
package com.falsepattern.lib.util;
import com.falsepattern.lib.StableAPI;
import com.falsepattern.lib.internal.Tags;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* 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!
*/
@StableAPI(since = "0.8.0")
public class AsyncUtil {
public static final ExecutorService asyncWorker = Executors.newSingleThreadExecutor((runnable) -> {
Thread thread = new Thread(runnable);
thread.setDaemon(true);
thread.setName(Tags.MODNAME + " Async Worker");
return thread;
});
}