Use virtual threads.

This commit is contained in:
Kavin 2023-09-20 00:45:07 +01:00
parent b3fd4f2ce9
commit 52229ed8c7
No known key found for this signature in database
GPG key ID: 6E4598CA5C92C41F
2 changed files with 3 additions and 3 deletions

View file

@ -53,11 +53,11 @@ public class Main {
System.exit(1);
}
Multithreading.runAsync(() -> new Thread(new SyncRunner(
Multithreading.runAsync(() -> Thread.ofVirtual().start(new SyncRunner(
new OkHttpClient.Builder().readTimeout(60, TimeUnit.SECONDS).build(),
MATRIX_SERVER,
MatrixHelper.MATRIX_TOKEN)
).start());
));
new Timer().scheduleAtFixedRate(new TimerTask() {
@Override

View file

@ -5,7 +5,7 @@ import java.util.function.Supplier;
public class Multithreading {
private static final ExecutorService es = Executors.newCachedThreadPool();
private static final ExecutorService es = Executors.newVirtualThreadPerTaskExecutor();
private static final ExecutorService esLimited = Executors
.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 8);
private static final ExecutorService esLimitedPubSub = Executors