41 lines
888 B
Java
41 lines
888 B
Java
package com.simulationservice.service;
|
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
/**
|
|
* 推演任务服务,用于创建线程和管理
|
|
*/
|
|
@Service
|
|
public class InferenceTaskService {
|
|
|
|
private DemandThread demandThread;
|
|
@Async
|
|
public boolean loadScenario(String roomId, String scenarioId) {
|
|
|
|
//
|
|
demandThread = new DemandThread();
|
|
demandThread.setRoomId(roomId);
|
|
demandThread.setScenarioId(scenarioId);
|
|
demandThread.start();
|
|
return true;
|
|
}
|
|
|
|
@Async
|
|
public void executeTask() {
|
|
demandThread.startThread();
|
|
}
|
|
|
|
@Async
|
|
public void stopTask() {
|
|
// 停止我们的任务
|
|
demandThread.stopThread();
|
|
}
|
|
|
|
@Async
|
|
public void closeTask() {
|
|
// 停止我们的任务
|
|
demandThread.closeThread();
|
|
}
|
|
}
|