mirror of
https://github.com/AsamK/signal-cli
synced 2025-09-03 04:50:37 +00:00
Use new threads API
This commit is contained in:
parent
8d55dfb66b
commit
ed8ac5b84c
7 changed files with 40 additions and 75 deletions
|
@ -55,8 +55,7 @@ public class JsonRpcReader {
|
|||
return;
|
||||
}
|
||||
|
||||
final var executor = Executors.newFixedThreadPool(10);
|
||||
try {
|
||||
try (final var executor = Executors.newCachedThreadPool()) {
|
||||
while (!Thread.interrupted()) {
|
||||
final var input = lineSupplier.get();
|
||||
if (input == null) {
|
||||
|
@ -72,8 +71,6 @@ public class JsonRpcReader {
|
|||
|
||||
executor.submit(() -> handleMessage(message, requestHandler, responseHandler));
|
||||
}
|
||||
} finally {
|
||||
Util.closeExecutorService(executor);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,8 +91,7 @@ public class JsonRpcReader {
|
|||
case JsonRpcBatchMessage jsonRpcBatchMessage -> {
|
||||
final var messages = jsonRpcBatchMessage.getMessages();
|
||||
final var responseList = new ArrayList<JsonRpcResponse>(messages.size());
|
||||
final var executor = Executors.newFixedThreadPool(10);
|
||||
try {
|
||||
try (final var executor = Executors.newCachedThreadPool()) {
|
||||
final var lock = new ReentrantLock();
|
||||
messages.forEach(jsonNode -> {
|
||||
final JsonRpcRequest request;
|
||||
|
@ -124,8 +120,6 @@ public class JsonRpcReader {
|
|||
}
|
||||
});
|
||||
});
|
||||
} finally {
|
||||
Util.closeExecutorService(executor);
|
||||
}
|
||||
|
||||
if (!responseList.isEmpty()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue