On the state machine below, let us suppose I am in "StateE". Then comes Sig1, so the transition is takes place. First I exit "StateE", then assume that the "Grd1" guard lets me throuh.
Now I enter "StateH", execute the entry action ("Act2"). Then I put a signal into the queue to execute the "do" action of the "StateH". This means that the "StateH" "do" action will be not necessary execute right after the enter action, but some other already scheduled signals may be served first.
Then I procees to "StateG". In "StateG" again, the entry action is executed ("Act2") and the "do" action is scheduled as a signal.
The signal dispatcher reaches the point in the signal queue where the StateH do action signal is.
The question is: Do we exit from StateG back to StateH before executing the do action of StateH or we can say: Being in StateG is also being in StateH, so no state transition is necessary, let us execute the StateH do action right away.
According to the UML Specification (formal-15-03-01, Sect. 14.2.3.4.3)
A State may also have an associated doActivity Behavior. This Behavior commences execution when the State is entered (but only after the State entry Behavior has completed) and executes concurrently with any other Behaviors that may be associated with the State, until: • it completes (in which case a completion event is generated) or • the State is exited, in which case execution of the doActivity Behavior is aborted.
This means that 1) doActivity is executed as soon as the state is entered (as opposed to your understanding) and 2) the doActivity keeps running while the State is active.
In your case, StateH
is active while StateG
is active (see definition of active state configuration), therefore, the doActivity of StateH
keeps running while you are in StateG