Код: Выделить всё
try (var scope = new StructuredTaskScope()) {
scope.fork(()->posRepo.findInspectionByUnitId(unitId));
scope.fork(()->posRepo.findEventOfFireByUnitId(unitId));
scope.fork(()->faultRepo.findGeneralErrorByUnitId(unitId));
scope.fork(()->ardInfRepo.findArdModeByUnitId(unitId));
scope.fork(()->ardInfRepo.findArdPowerStatusByUnitId(unitId));
scope.fork(()->ardInfRepo.findArdModeByUnitId(unitId));
// Once a task return true, close all remaining tasks,and return the signal:"true" to main task;
scope.join();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
Код: Выделить всё
public interface ElePosRepo extends CrudRepository {
Optional findInspectionByUnitId(Integer unitId);
Optional findEventOfFireByUnitId(Integer unitId);
}
Подробнее здесь: https://stackoverflow.com/questions/782 ... rrency-api