sequenceDiagram
Thread 1 ->> CPU 1: Execute
CPU 1 --> Thread 1: Done
Thread 2 ->> CPU 2: Execute
CPU 2 --> Thread 2: Done
Exceptions Example
- In example below, Method 2 can either catch the exception or throw it to method 1 to deal with
graph LR
A(Main) --> B(Method1)
B --> C(Method2: Exception!!)
C --> D(Method3)
What we hope happens
sequenceDiagram
Withdraw --> Balance:
Note right of Balance: balance=100
Balance ->> Deposit: 100
Note right of Deposit: Dep = 100+100 = 200
Deposit ->> Balance: 200
Note right of Balance: balance=200
Balance ->> Withdraw: 200
Note left of Withdraw: Wit = 200-100 = 100
Withdraw ->> Balance: 100
Note right of Balance: balance=200
What might very well happen instead
sequenceDiagram
Withdraw --> Balance:
Note right of Balance: balance=100
Balance ->> Deposit: balance: 100
Note right of Deposit: Dep = 100+100 = 200
Balance ->> Withdraw: balance: 100
Note right of Withdraw: Wit = 100-100 = 0
Withdraw ->> Balance: set: 0
Note right of Balance: balance=0
Deposit ->> Balance: 200
Note right of Balance: balance=200