diff --git a/northstar-main/src/main/java/org/dromara/northstar/event/BroadcastHandler.java b/northstar-main/src/main/java/org/dromara/northstar/event/BroadcastHandler.java index a462bcac6c93878125ceb238d27035a19ea3129d..b10149943fe098c1f028b67fa267134556dc7bb1 100644 --- a/northstar-main/src/main/java/org/dromara/northstar/event/BroadcastHandler.java +++ b/northstar-main/src/main/java/org/dromara/northstar/event/BroadcastHandler.java @@ -35,7 +35,7 @@ public class BroadcastHandler extends AbstractEventHandler implements GenericEve private SocketIOServer socketServer; - private ExecutorService exec = Executors.newSingleThreadExecutor(); + private ExecutorService exec = Executors.newVirtualThreadPerTaskExecutor(); private static final Set TARGET_TYPE = EnumSet.of( NorthstarEventType.TICK, diff --git a/northstar-main/src/main/java/org/dromara/northstar/event/DisruptorFastEventEngine.java b/northstar-main/src/main/java/org/dromara/northstar/event/DisruptorFastEventEngine.java index 986d6620c0dfc8ec8baa6d8e576adef55674053f..72b9e94e11b0dd3be9b3ae4df3317051c7350a7d 100644 --- a/northstar-main/src/main/java/org/dromara/northstar/event/DisruptorFastEventEngine.java +++ b/northstar-main/src/main/java/org/dromara/northstar/event/DisruptorFastEventEngine.java @@ -36,7 +36,7 @@ import xyz.redtorch.pb.CoreField.NoticeField; @Slf4j public class DisruptorFastEventEngine implements FastEventEngine, DisposableBean { - private static final ExecutorService executor = Executors.newCachedThreadPool(DaemonThreadFactory.INSTANCE); + private static final ExecutorService executor = Executors.newVirtualThreadPerTaskExecutor(); private static final int BUF_SIZE = 65536; private final Map, BatchEventProcessor> handlerProcessorMap = new ConcurrentHashMap<>(); diff --git a/northstar-main/src/main/java/org/dromara/northstar/event/SimMarketHandler.java b/northstar-main/src/main/java/org/dromara/northstar/event/SimMarketHandler.java index 4153dba4758ba0ce332dbc1e9fa49822c677f545..ebce3fded0044873509fb4c5d240ff2ad9e4b999 100644 --- a/northstar-main/src/main/java/org/dromara/northstar/event/SimMarketHandler.java +++ b/northstar-main/src/main/java/org/dromara/northstar/event/SimMarketHandler.java @@ -17,7 +17,7 @@ import org.dromara.northstar.gateway.sim.trade.SimTradeGateway; public class SimMarketHandler extends AbstractEventHandler implements GenericEventHandler{ - private Executor exec = Executors.newSingleThreadExecutor(); // 增加一个工作线程解耦TICK事件可能导致的死锁问题 + private Executor exec = Executors.newVirtualThreadPerTaskExecutor(); // 增加一个工作线程解耦TICK事件可能导致的死锁问题 private GatewayManager gatewayMgr; diff --git a/northstar-main/src/main/java/org/dromara/northstar/module/ArbitrageModuleContext.java b/northstar-main/src/main/java/org/dromara/northstar/module/ArbitrageModuleContext.java index 0ebf2855489c85ef53d42a4d8e37a05fc5078773..da12a22ceb20265f354270579451d87f8d11e66f 100644 --- a/northstar-main/src/main/java/org/dromara/northstar/module/ArbitrageModuleContext.java +++ b/northstar-main/src/main/java/org/dromara/northstar/module/ArbitrageModuleContext.java @@ -40,7 +40,7 @@ import xyz.redtorch.pb.CoreEnum.TimeConditionEnum; public class ArbitrageModuleContext extends ModuleContext implements IModuleContext{ - private ExecutorService exec = Executors.newFixedThreadPool(2); + private ExecutorService exec = Executors.newVirtualThreadPerTaskExecutor(); private final Logger logger; diff --git a/northstar-main/src/main/resources/application.yml b/northstar-main/src/main/resources/application.yml index 5fbe3e10c720754949f3fd90ca431214c362ba26..4129f4ddc967f2baee6e93153a7878bb301ddce1 100644 --- a/northstar-main/src/main/resources/application.yml +++ b/northstar-main/src/main/resources/application.yml @@ -30,7 +30,9 @@ spring: database-platform: org.hibernate.dialect.H2Dialect profiles: active: ${env:dev} - + threads: + virtual: + enabled: true --- server: port: 443