mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-09-03 17:52:30 +02:00
concurrent fix
This commit is contained in:
parent
146331b3ac
commit
f7e9c26746
@ -1,13 +1,13 @@
|
|||||||
package stirling.software.SPDF.utils;
|
package stirling.software.SPDF.utils;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.concurrent.Semaphore;
|
import java.util.concurrent.Semaphore;
|
||||||
public class ProcessExecutor {
|
public class ProcessExecutor {
|
||||||
|
|
||||||
@ -16,7 +16,8 @@ public class ProcessExecutor {
|
|||||||
OCR_MY_PDF
|
OCR_MY_PDF
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Map<Processes, ProcessExecutor> instances = new HashMap<>();
|
private static final Map<Processes, ProcessExecutor> instances = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
|
||||||
private final Semaphore semaphore;
|
private final Semaphore semaphore;
|
||||||
|
|
||||||
@ -27,7 +28,7 @@ public class ProcessExecutor {
|
|||||||
public static ProcessExecutor getInstance(Processes processType) {
|
public static ProcessExecutor getInstance(Processes processType) {
|
||||||
return instances.computeIfAbsent(processType, key -> {
|
return instances.computeIfAbsent(processType, key -> {
|
||||||
int semaphoreLimit = switch (key) {
|
int semaphoreLimit = switch (key) {
|
||||||
case LIBRE_OFFICE -> 2;
|
case LIBRE_OFFICE -> 1;
|
||||||
case OCR_MY_PDF -> 2;
|
case OCR_MY_PDF -> 2;
|
||||||
};
|
};
|
||||||
return new ProcessExecutor(semaphoreLimit);
|
return new ProcessExecutor(semaphoreLimit);
|
||||||
|
Loading…
Reference in New Issue
Block a user