Use virtual threads

This commit is contained in:
AsamK 2026-01-24 14:57:30 +01:00
parent 32c8d4f801
commit 0bd4d554d8
7 changed files with 21 additions and 7 deletions

View File

@ -212,6 +212,17 @@
}
]
},
{
"type": "com.sun.crypto.provider.HKDFKeyDerivation$HKDFSHA384",
"methods": [
{
"name": "<init>",
"parameterTypes": [
"javax.crypto.KDFParameters"
]
}
]
},
{
"type": "com.sun.crypto.provider.HmacCore$HmacSHA256",
"methods": [
@ -1006,6 +1017,9 @@
}
]
},
{
"type": "java.lang.VirtualThread"
},
{
"type": "java.lang.annotation.Retention",
"methods": [

File diff suppressed because one or more lines are too long

View File

@ -20,7 +20,7 @@ public class JobExecutor implements AutoCloseable {
public JobExecutor(final Context context) {
this.context = context;
this.executorService = Executors.newCachedThreadPool();
this.executorService = Executors.newVirtualThreadPerTaskExecutor();
}
public void enqueueJob(Job job) {

View File

@ -157,7 +157,7 @@ public class ManagerImpl implements Manager {
private final SignalDependencies dependencies;
private final Context context;
private final ExecutorService executor = Executors.newCachedThreadPool();
private final ExecutorService executor = Executors.newVirtualThreadPerTaskExecutor();
private Thread receiveThread;
private boolean isReceivingSynchronous;

View File

@ -59,7 +59,7 @@ public class HttpServerHandler implements AutoCloseable {
logger.debug("Starting HTTP server on {}", address);
server = HttpServer.create(address, 0);
server.setExecutor(Executors.newCachedThreadPool());
server.setExecutor(Executors.newVirtualThreadPerTaskExecutor());
server.createContext("/api/v1/rpc", this::handleRpcEndpoint);
server.createContext("/api/v1/events", this::handleEventsEndpoint);

View File

@ -55,7 +55,7 @@ public class JsonRpcReader {
return;
}
try (final var executor = Executors.newCachedThreadPool()) {
try (final var executor = Executors.newVirtualThreadPerTaskExecutor()) {
while (!Thread.interrupted()) {
final var input = lineSupplier.get();
if (input == null) {
@ -91,7 +91,7 @@ public class JsonRpcReader {
case JsonRpcBatchMessage jsonRpcBatchMessage -> {
final var messages = jsonRpcBatchMessage.getMessages();
final var responseList = new ArrayList<JsonRpcResponse>(messages.size());
try (final var executor = Executors.newCachedThreadPool()) {
try (final var executor = Executors.newVirtualThreadPerTaskExecutor()) {
final var lock = new ReentrantLock();
messages.forEach(jsonNode -> {
final JsonRpcRequest request;

View File

@ -63,7 +63,7 @@ public class SocketHandler implements AutoCloseable {
logger.debug("Starting JSON-RPC server on {}", address);
listenerThread = Thread.ofPlatform().name("daemon-listener").start(() -> {
try (final var executor = Executors.newCachedThreadPool()) {
try (final var executor = Executors.newVirtualThreadPerTaskExecutor()) {
logger.info("Started JSON-RPC server on {}", address);
while (true) {
final var connectionId = threadNumber.getAndIncrement();