It is important to know exactly what the order is of the execution of statechart elements' actions. For this reason we present the following algorithm.
When a transition is taken, transition and state actions are executed in the following order:
Actions associated with statechart elements (states and transitions) are executed atomically and in zero model time. Therefore they cannot contain synchronization and delay operations, or call functions directly or indirectly containing them.
Execution order illustration
Consider the example shown in. Suppose
N
is the current simple state and transition
T1
has been selected to be taken. Then the actions are executed in the following order:
Then the transition
T2
or
T3
is selected depending on guards of the transitions. In case the selected transition is
T2, the following actions are executed:
In case the selected transition is
T3, the following actions are executed: