Skip to content
Tutorials Center
My learning

Topics

Lesson 14 of 39 ยท Use Case and Activity Diagrams

Swimlanes, Forks and Joins

Extend activity diagrams with swimlanes to show who does what, forks and joins for parallel work, object flows, signals and interruptible regions, with examples and code.

The basic activity diagram shows what happens and in what order. Two additions make it far more useful for real processes. Swimlanes show who is responsible for each action. Forks and joins show work that happens in parallel. Together they turn a flowchart into a proper model of a business process.

Swimlanes (partitions)

A swimlane is a vertical or horizontal band labelled with a role, a department or a system. Every action sits in the lane of whoever (or whatever) performs it. Arrows crossing lanes show handovers.

Mermaid has no swimlanes, but subgraphs give the same layout. Each subgraph below is one lane.

flowchart TD
    subgraph Customer
        A(("Start")) --> B["Place order"]
        H["Receive goods"] --> I(("End"))
    end
    subgraph Sales
        C["Check order"] --> D{"Valid?"}
        D -- "[no]" --> J["Reject order"]
    end
    subgraph Warehouse
        E["Pick items"] --> F["Pack parcel"]
        F --> G["Ship parcel"]
    end
    B --> C
    D -- "[yes]" --> E
    G --> H
    J --> I

Three lanes: Customer, Sales and Warehouse. Each crossing arrow is a handover and a place where delays and misunderstandings happen.

What lanes tell you at a glance:

  • Responsibility: who must act at each step.
  • Handovers: many crossings mean a chatty, slow process.
  • Bottlenecks: one lane crowded with actions may be overloaded.

Lanes can be roles, departments, organizations, or software components. Pick one kind per diagram.

Fork and join: parallel flows

A fork is a thick bar that splits one flow into several that run concurrently. A join is a thick bar that waits for all incoming flows before continuing. This is where the difference from decision and merge matters:

Node Shape Behavior
Decision diamond Sends the token down one path
Merge diamond Lets any incoming token through
Fork bar Sends tokens down all paths at once
Join bar Waits for all tokens, then continues

Mermaid draws a bar with a rectangle that you can make thin, like Fork[" "]; the style below uses a fork-shaped label instead.

flowchart TD
    S(("Start")) --> A["Take payment"]
    A --> F1["FORK"]
    F1 --> B["Pack items"]
    F1 --> C["Send confirmation email"]
    F1 --> D["Update inventory"]
    B --> J1["JOIN"]
    C --> J1
    D --> J1
    J1 --> E["Ship parcel"]
    E --> Z(("End"))

After payment, three things happen at once. Shipping waits at the join until all of them are done.

Rules of thumb:

  • Every fork should have a matching join (or the parallel flows must each end separately).
  • A join with a missing input never fires. That is deadlock, a classic modeling bug.
  • Concurrency here is logical. It says "these steps do not depend on each other", not "use threads".
Python Fork and join with asyncio

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The branches finish in whatever order their work takes (here by delay, in a real system it can vary); the model guarantees only what happens after the join. That is an important point to make in your diagrams: parallel branches should not rely on each other's order.

Python A token simulator: decision vs fork

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Object flows

Besides control flow, activities can show objects moving between actions: a rectangle (an object node) like Order [validated] placed on an arrow, or pins (small squares) on the action. This tells readers what data passes between steps, and in which state.

flowchart LR
    A["Check order"] --> O1["Order<br/>validated"]
    O1 --> B["Pick items"]
    B --> O2["Parcel<br/>packed"]
    O2 --> C["Ship parcel"]

Object nodes between actions: the Order is passed along in the state validated, then a Parcel in the state packed.

Other useful features

  • Signals: a send signal action fires an event outward; an accept event action waits for one. Example: "Accept payment received".
  • Time events: an hourglass node waits for a time to pass ("after 24 hours").
  • Interruptible regions: a dashed rounded region in which a cancel event aborts all actions. Typical use: "Cancel order" while packing.
  • Subactivities: an action marked with a rake symbol stands for a whole nested activity. This keeps top diagrams small.
  • Notes and constraints: add {pre: stock > 0} or {post: shipped} when they clarify.

Tools for richer activities

Swimlanes Who does each step.
Fork and join Parallel work, then sync.
Object flow What data moves.
Events and time Wait for signals.

Add features only when they answer a question.

1 / 2

A complete small example

Return of a parcel: lanes, a decision and a fork combine.

flowchart TD
    subgraph Customer
        S(("Start")) --> A["Request return"]
        A2["Send item back"]
    end
    subgraph Support
        B["Approve return"] --> C{"Within 30 days?"}
        C -- "[no]" --> R["Reject request"]
    end
    subgraph Finance
        F["Refund payment"]
    end
    subgraph Warehouse
        W["Inspect item"] --> W2["Restock item"]
    end
    A --> B
    C -- "[yes]" --> A2
    A2 --> W
    W --> F
    W2 --> E(("End"))
    F --> E
    R --> E

Notice how the lanes reveal that Finance cannot act before Warehouse has inspected the item, a rule hidden in a plain list of steps.

Common mistakes

  • Fork without join where later steps expect all results.
  • Decisions used as forks (or the reverse): a decision picks one path, a fork starts all of them.
  • Too many lanes. More than five or six makes the diagram unreadable; split the process.
  • Action in two lanes. Each action has one responsible lane; if two parties share a task, model it as two actions with a handover.
  • Parallel steps that secretly depend on each other.

If you cannot decide whether two steps are parallel, ask: could the second one start if the first took a week? If yes, they are parallel; if not, they are sequential.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. What does a swimlane represent?

    Lanes partition the diagram by responsibility.
  2. 2. What does a join node do?

    Joins synchronize parallel flows.
  3. 3. Which describes a decision node?

    A decision is exclusive routing; a fork is the parallel counterpart.
  4. 4. What problem arises when a join has an input that never receives a token?

    The join waits forever for the missing token.
  5. 5. What are object nodes used for in activity diagrams?

    Object flows describe the data moving between steps.

Summary

  • Swimlanes assign each action to a role or system and expose handovers.
  • Forks start parallel flows; joins wait for all of them. Decisions and merges are exclusive.
  • Object nodes show data and its state moving between actions.
  • Signals, time events, interruptible regions and subactivities handle richer behavior.
  • Use features sparingly: every added symbol should answer a question.

Next: Sequence Diagram Basics