Проект

Общее

Профиль

FSM Fork and Join (Parallel execution)

@Override
public void configure(StateMachineStateConfigurer<String, String> states) throws Exception {
    states
        .withStates()
        .initial("SI")
        .fork("S1")
        .join("JOIN")
        .state("S11")
        .state("S12")
        .state("S2")
        .end("END")
        .and()
        .withStates()
            .parent("S1")
            .initial("S11")
            .end("S11") //not very sure about this
        .and()
        .withStates()
            .parent("S1")
            .initial("S12")
            .end("S12");
}
@Override
public void configure(StateMachineTransitionConfigurer<String, String> transitions) throws Exception {
    transitions.withExternal()
                .source("SI").target("S1").event("YOUR_EVENT")
             .and()
             .withExternal()
                .source("S2").target("END").event("YOUR_EVENT")
            .and()
            .withFork()
                .source("S1")
                .target("S11")
                .target("S12")
            .and()
            .withJoin()
                .source("S11")
                .source("S12")
                .target("JOIN");
}