UML 状态机中是否可以有多个活动状态

Can there be more than one active state in a UML state machine

我理解在复合状态下可以同时存在正交区域运行。 在 UML 状态机中,任何时候都可以有多个活动状态吗?

是的,每当 运行-to-completion 步骤完成时,可以有超过 1 个活动状态。实际上可以有一整棵活动状态树:

如你所说,复合状态的正交区域可以有活跃状态。复合状态也可以递归嵌套。这意味着如果嵌套状态处于活动状态,则其所有祖先也处于活动状态。因此,正交区域和嵌套复合状态的组合可以导致一整棵活动状态树。

UML Superstructure Specification, v2.4.1是这样解释的(第15.3.11章状态第564页):

Active state configurations

In a hierarchical state machine more than one state can be active at the same time. If the state machine is in a simple state that is contained in a composite state, then all the composite states that either directly or transitively contain the simple state are also active. Furthermore, since the state machine as a whole and some of the composite states in this hierarchy may be orthogonal (i.e., containing regions), the current active “state” is actually represented by a set of trees of states starting with the top-most states of the root regions down to the innermost active substate. We refer to such a state tree as a state configuration.

挑剔的可以例外:

如果状态机终止,当然根本没有活动状态,因此此时不可能有多个活动状态。

备注

UML 上层结构规范 v2.4.1 是 文档以检查您是否有此类问题。