How to illustrate multiple threads in sequence diagram?

MultithreadingUmlSequence Diagram

Multithreading Problem Overview


How can you clearly illustrate multiple threads of execution in a sequence diagram or similar diagram?

I haven't been able to find any clear examples. All diagrams I see are used to illustrate a single thread.


Update: The accepted answer was the best example I saw but it does leave a fair bit to be desired. I ended up illustrating the threads in separate sequence diagrams. I'm not sure if the sequence diagram necessarily works for multiple threads.

Multithreading Solutions


Solution 1 - Multithreading

Here is one diagram that may be useful, and on the left-hand side you can see the explanation: http://sdedit.sourceforge.net/multithreading/example/index.html

Multithreading Sequence Diagram

Solution 2 - Multithreading

I found this question on Google and wasn't a huge fan of the accepted answer so I just came up with my own. This is how I represented the threading model in my application (my organization calls it the 'Concurrency Viewpoint'):

Concurrency viewpoint

Hopefully it helps someone.

Solution 3 - Multithreading

This is a duplicate of sihaya's answer, but with details on how to accomplish it with tools on the web and a visual example that will not disappear.

The UML Sequence diagram approach is to use the "par" fragment to model multiple messages being processed in parallel. Below is a text description which when fed into the PlantUML tool available on the web will produce the diagram below.

@startuml

Person -> MicrowaveOven : Cook Food
activate MicrowaveOven
par
MicrowaveOven -> MicrowaveOven : Activate Magnetron
else
MicrowaveOven -> MicrowaveOven : Activate Rotation Motor
end

MicrowaveOven --> Person : Delicious Food
deactivate MicrowaveOven

@enduml

par UML example

Solution 4 - Multithreading

You can use a "par" fragment to model multiple synchronous calls being executed in parallel. The fragment consists of a rectangle with the label "par". The rectangle is divided into multiple boxes, each representing a thread of execution.

Below an example extracted from the link.

enter image description here

An example is given on this page: http://www.ibm.com/developerworks/rational/library/3101.html#N10227

Solution 5 - Multithreading

I like @Brandon's answer. That's a diagram that shows a clear threading communication model.

I also came across this document which has several different approaches https://www.omg.org/ocup-2/documents/concurrency_in_uml_version_2.6.pdf

Solution 6 - Multithreading

You may be interested in Message Sequence Charts, or MSC.

Here is a slide describing MSC in a nutshell.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMarcus LeonView Question on Stackoverflow
Solution 1 - MultithreadingJames BlackView Answer on Stackoverflow
Solution 2 - MultithreadingBrandonView Answer on Stackoverflow
Solution 3 - MultithreadingReginald BlueView Answer on Stackoverflow
Solution 4 - MultithreadingsihayaView Answer on Stackoverflow
Solution 5 - MultithreadingxaviersjsView Answer on Stackoverflow
Solution 6 - MultithreadingmouvicielView Answer on Stackoverflow