title: Execute state actions synchronously
body: <p>I am using a spring state machine with multiple regions, and I configure some region to have entryAction and exitAction.</p>
  
  <p>I recently realized that the callback for the actions where run in a different thread and sometimes they don't complete until after the state transition is done.</p>
  
  <p>Here's the stack trace for when the actions get scheduled:</p>
  
  <pre><code>    at org.springframework.statemachine.state.AbstractState.entry(AbstractState.java:208)
      at org.springframework.statemachine.state.ObjectState.entry(ObjectState.java:156)
      at org.springframework.statemachine.support.AbstractStateMachine.entryToState(AbstractStateMachine.java:1216)
      at org.springframework.statemachine.support.AbstractStateMachine.entryToState(AbstractStateMachine.java:1161)
      at org.springframework.statemachine.support.AbstractStateMachine.setCurrentStateInternal(AbstractStateMachine.java:971)
      at org.springframework.statemachine.support.AbstractStateMachine.setCurrentState(AbstractStateMachine.java:949)
      at org.springframework.statemachine.support.AbstractStateMachine.setCurrentState(AbstractStateMachine.java:944)
      at org.springframework.statemachine.support.AbstractStateMachine.setCurrentStateInternal(AbstractStateMachine.java:1038)
      at org.springframework.statemachine.support.AbstractStateMachine.setCurrentState(AbstractStateMachine.java:949)
      at org.springframework.statemachine.support.AbstractStateMachine.switchToState(AbstractStateMachine.java:841)
      at org.springframework.statemachine.support.AbstractStateMachine.access$400(AbstractStateMachine.java:77)
      at org.springframework.statemachine.support.AbstractStateMachine$2.transit(AbstractStateMachine.java:301)
      at org.springframework.statemachine.support.DefaultStateMachineExecutor.handleTriggerTrans(DefaultStateMachineExecutor.java:248)
      at org.springframework.statemachine.support.DefaultStateMachineExecutor.processTriggerQueue(DefaultStateMachineExecutor.java:395)
      at org.springframework.statemachine.support.DefaultStateMachineExecutor.access$100(DefaultStateMachineExecutor.java:61)
      at org.springframework.statemachine.support.DefaultStateMachineExecutor$1.run(DefaultStateMachineExecutor.java:281)
      at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50)
      at org.springframework.statemachine.support.DefaultStateMachineExecutor.scheduleEventQueueProcessing(DefaultStateMachineExecutor.java:300)
      at org.springframework.statemachine.support.DefaultStateMachineExecutor.execute(DefaultStateMachineExecutor.java:144)
      at org.springframework.statemachine.support.AbstractStateMachine.sendEventInternal(AbstractStateMachine.java:559)
      at org.springframework.statemachine.support.AbstractStateMachine.sendEvent(AbstractStateMachine.java:211)
  </code></pre>
  
  <p>To avoid race conditions and make sure that the state entry/exit actions are finished once the <code>sendEvent</code> function is done, I would like to use a Synchronous task scheduler, but I don't think there's such a thing (I would have to implement my own). Or is there another way to make sure my entry/exit actions are done after the transition?</p>