Spring state machine nested machines running synchronously
<p>I'm working with the Spring State Machine and am trying to configure some nested functionality.  Essentially, I'm trying to run two processes as individual machines nested within a state.  I have the following code for states and transitions:</p>

<pre><code>public enum States {
READY, FORK, JOIN, TASKS, TERMINATE,

T1_INIT, C1_INIT, T1_READY, T1_POLL, T1_PROCESS, T1_STORE, T1_DELAY, C1_CONTINUE, T1_TERMINATE,
T2_INIT, C2_INIT, T2_READY, T2_POLL, T2_PROCESS, T2_STORE, T2_DELAY, C2_CONTINUE, T2_TERMINATE }

public enum Events {INITIALIZE, RUN, STOP, FALLBACK, CONTINUE, FIX, PROC_COMPLETE}
@Override
public void configure(StateMachineStateConfigurer&lt;States, Events&gt; states)
        throws Exception {
    states
            .withStates()
            .initial(States.READY)
            .fork(States.FORK)
            .state(States.TASKS)
            .join(States.JOIN)
            .end(States.TERMINATE)
            .and()
            .withStates()
            .parent(States.TASKS)
            .initial(States.T1_INIT, initT1Action())
            .state(States.T1_READY)
            .state(States.T1_POLL, pollT1Action(), null)
            .state(States.T1_PROCESS, processT1Action(), null)
            .state(States.T1_STORE, storeT1Action(), null)
            .state(States.T1_DELAY)
            .choice(States.C1_CONTINUE)
            .end(States.T1_TERMINATE)
            .and()
            .withStates()
            .parent(States.TASKS)
            .initial(States.T2_INIT, initT2Action())
            .state(States.T2_READY)
            .state(States.T2_POLL, pollT2Action(), null)
            .state(States.T2_PROCESS, processT2Action(), null)
            .state(States.T2_STORE, storeT2Action(), null)
            .state(States.T2_DELAY)
            .choice(States.C2_CONTINUE)
            .end(States.T2_TERMINATE);

}

@Override
public void configure(StateMachineTransitionConfigurer&lt;States, Events&gt; transitions)
        throws Exception {
    transitions
            .withExternal()
            .source(States.READY).target(States.FORK)
            .and()
            .withFork()
            .source(States.FORK).target(States.TASKS)
            .and()
            .withExternal()
            .source(States.T1_INIT).target(States.T1_READY)
            .and()
            .withExternal()
            .source(States.T1_READY).target(States.T1_POLL)
            .and()
            .withExternal()
            .source(States.T1_POLL).target(States.T1_PROCESS).guard(pollT1Guard())
            .and()
            .withExternal()
            .source(States.T1_PROCESS).target(States.T1_STORE).guard(processT1Guard())
            .and()
            .withExternal()
            .source(States.T1_STORE).target(States.T1_DELAY).guard(storeT1Guard())
            .and()
            .withExternal()
            .source(States.T1_DELAY).target(States.C1_CONTINUE)
            .and()
            .withChoice()
            .source(States.C1_CONTINUE)
            .first(States.T1_POLL, continueChoiceT1Guard())
            .last(States.T1_TERMINATE)
            .and()
            .withExternal()
            .source(States.T2_INIT).target(States.T2_READY)
            .and()
            .withExternal()
            .source(States.T2_READY).target(States.T2_POLL)
            .and()
            .withExternal()
            .source(States.T2_POLL).target(States.T2_PROCESS).guard(pollT2Guard())
            .and()
            .withExternal()
            .source(States.T2_PROCESS).target(States.T2_STORE).guard(processT2Guard())
            .and()
            .withExternal()
            .source(States.T2_STORE).target(States.T2_DELAY).guard(storeT2Guard())
            .and()
            .withExternal()
            .source(States.T2_DELAY).target(States.C2_CONTINUE)
            .and()
            .withChoice()
            .source(States.C2_CONTINUE)
            .first(States.T2_POLL, continueChoiceT2Guard())
            .last(States.T2_TERMINATE)
            .and()
            .withJoin()
            .source(States.TASKS).target(States.JOIN)
            .and()
            .withExternal()
            .source(States.JOIN).target(States.TERMINATE);

}
</code></pre>

<p>I was expecting the machine to fork the two machines identified in the Task state and run them as individual machines.  T1 and T2 actions are set up to have a delay in each state within Task.  T1 is delayed 1 second, and T2 is delayed half a second.</p>

<p>What I find is T1 runs through all of it's states and ends before T2 even starts.  Any thoughts on making them run as they should with a fork/join??</p>