Activity diagrams: time events
Introduction
A “time event” is one of the most frequently overlooked semantics in UML activity diagrams: a waiting activity does not wait forever, it is interrupted by a time condition and takes a different branch. An approval that auto-passes after five minutes with no human action, a cache that falls back to the origin after thirty seconds, a retry that gives up after three attempts — all of these are time events.
The catch is that neither PlantUML nor Mermaid has a timeout keyword you can write to say “fires after 5 minutes”. This article draws the same situation with the most natural mechanism each engine offers, and spells out where they differ on concurrency and on real time.
PlantUML version
PlantUML’s activity diagram (activity beta syntax) has no timeout keyword. To express “waiting for the approval result” and “waiting for a 5-minute timeout” as two parallel paths, fork / fork again is the closest thing to real UML semantics:
1 | @startuml |
fork opens a parallel branch, fork again adds a second one, and end fork merges them back. The two branches stand for two things running at once: a human on one side, a countdown on the other. Whichever branch reaches the merge point first decides the outcome.
If all you want to express is “interrupt the current activity on timeout”, detach is more precise — the activity flow leaves the main path here and waits for an external event (possibly a timer) before coming back:
1 | @startuml |
The note right is only an annotation and does not change the structural semantics of the diagram. To make the time condition visible in the diagram itself, a split / split again branch is more accurate than a note.
Mermaid version
Mermaid has no activity diagram type, so flowchart is the closest equivalent. Draw the same situation as a flowchart, with the waiting state branching to a timeout path via a labelled edge:
1 | flowchart TD |
The |超时 5 分钟| on the edge is Mermaid’s most natural way to express a time condition: the condition lives on the edge and the nodes stay clean. The cost is that this chart has no concurrency semantics — the two edges read like “choose one of these in sequence” rather than “wait on both at once”.
When the time relationship is itself the subject (rather than a condition on one branch), gantt is the right tool in Mermaid, because it has a real timeline and milestones:
1 | gantt |
milestone marks a point on the timeline (the moment the timeout fires) and active marks a task as in progress. Note that gantt requires section grouping and that task rows use the task name : status, id, start, end form.
Side-by-side
| Aspect | PlantUML | Mermaid |
|---|---|---|
| Diagram type | Native activity diagram (activity beta) | No activity diagram; approximated with flowchart |
| Parallel branches | fork / fork again / end fork |
No parallel syntax; only visual implication via edges |
| Time condition | Branch structure plus a note annotation |
Written on the edge: `B –> |
| Interrupting a wait | detach (waits for an external event) |
No keyword; use a dotted -.-> edge for a weak relation |
| Real timeline | None (you do the arithmetic) | gantt natively supports timelines and milestone |
Wrap-up
The two engines are almost opposites here: PlantUML has the UML activity structure (parallelism, interruption, merge) but no time primitive, while Mermaid has a genuine timeline (gantt) but no activity structure. The most practical combination is usually to draw the structure in PlantUML (fork to show “the human and the clock are both waiting”), express the condition in Mermaid with a labelled edge on a flowchart, and switch to gantt only when a real calendar view is what you actually need.
- Title: Activity diagrams: time events
- Author: puml.online
- Created at : 2026-11-28 16:13:00
- Updated at : 2026-12-05 02:08:58
- Link: https://puml.online/blog/activity-diagram-time-event-en/
- License: This work is licensed under CC BY-NC-SA 4.0.