State diagrams: concurrent regions
简介 / Introduction
A state machine often runs two independent things at once: an order is being paid for while the warehouse reserves stock, and the order only closes when both finish. If you chain those two phases into one line, you lose the “happens at the same time” semantics. PlantUML splits a composite state into concurrent regions with a -- separator; Mermaid has no separator support and expresses concurrency with <<fork>> / <<join>> nodes instead. This post walks through the same order flow in both engines and explains the trade-offs.
PlantUML 版
In PlantUML, concurrent regions must live inside a composite state: open one with state "Name" as alias { ... }, list the child states in order, and put a lone -- line between them. Everything after the -- belongs to the second region and advances in parallel with the states of the first region.
1 | [*] --> Idle |
Key points:
--is only legal inside a composite state block; at the top level it is a syntax error.- State names inside a region are scoped to the composite state, so a name like
Validatecannot be referenced from outside. - Nesting is allowed: the
Paymentcomposite state can hold its own child states and its own--. - Put transitions inside the region they belong to, pointing at another state in the same region, so the reader can see that no transition crosses a concurrency boundary.
- Entering and leaving the composite state as a whole (
Idle --> OP,OP --> [*]) expresses “all regions are done”.
Mermaid 版
Mermaid v11’s stateDiagram-v2 has no -- separator syntax; writing one fails with No such shape: divider. Concurrency is expressed with the built-in <<fork>> and <<join>> stereotypes: a fork splits one incoming transition into several parallel branches, and a join collects the branches back together.
1 | stateDiagram-v2 |
Key points:
state fork_state <<fork>>andstate join_state <<join>>are built-in Mermaid stereotypes; no extra plugin is needed.- The fork’s incoming edge connects to the fork node, and its outgoing edges go to the start of each parallel branch; on the way back, every branch’s end connects to the join node.
- Mermaid composite states only support nesting — there is no “side-by-side region” concept, so
PaymentandFulfilmentinsideOrder Processingare simply two sibling substates rather than regions cut apart by a divider. - The concurrency semantics come from the fork/join convention rather than a structural constraint, so the reader has to interpret the split and the merge.
对比 / Side-by-side
| Aspect | PlantUML | Mermaid |
|---|---|---|
| How concurrency is expressed | A -- separator inside a composite state cuts out side-by-side regions |
<<fork>> / <<join>> nodes model the split and the merge |
| Separator syntax | A lone -- line, only inside a composite state block |
Not supported — writing it raises No such shape: divider |
| Regions vs. branches | The separator defines the regions directly; structurally they are parallel | Each outgoing edge of the fork is one parallel branch |
| Composite states | Multi-level nesting, and -- can be nested too |
Nesting is supported, but nesting levels carry no “parallel” meaning |
| Where transitions live | Inside the region they belong to, never crossing a region boundary | Written outside the fork/join, pointing at concrete states |
| Completion semantics | Entering and leaving the composite state as a whole naturally means “everything finished” | Requires an explicit join node before the final transition |
小结 / Wrap-up
Concurrent regions are the standard way to show “these happen at the same time” in a state diagram. PlantUML models concurrency structurally with -- inside a composite state, so region boundaries are obvious and transitions cannot accidentally cross them. Mermaid v11 takes the node route with fork/join: semantically equivalent, but the reader has to understand the split-and-merge convention. Pick based on which matters more to you — structural clarity favours PlantUML, ecosystem consistency with Mermaid favours fork/join.
- Title: State diagrams: concurrent regions
- Author: puml.online
- Created at : 2026-11-13 01:09:32
- Updated at : 2026-11-26 01:07:01
- Link: https://puml.online/blog/state-diagram-concurrent-regions-en/
- License: This work is licensed under CC BY-NC-SA 4.0.