Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to illustrate multiple threads in sequence diagram?

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.

like image 209
Marcus Leon Avatar asked Oct 29 '09 13:10

Marcus Leon


People also ask

How do you show multiple threads in a sequence diagram?

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.

What is multiple threading with example?

What is MultiThreading? Multithreading enables us to run multiple threads concurrently. For example in a web browser, we can have one thread which handles the user interface, and in parallel we can have another thread which fetches the data to be displayed. So multithreading improves the responsiveness of a system.

How do you show parallel execution in a sequence diagram?

The parallel combination fragment element should be used when creating a sequence diagram that shows parallel processing activities. The parallel combination fragment is drawn using a frame, and you place the text “par” in the frame's namebox.

Can a single process have multiple number of threads?

In a multithreaded process on a single processor, the processor can switch execution resources between threads, resulting in concurrent execution. Concurrency indicates that more than one thread is making progress, but the threads are not actually running simultaneously.


2 Answers

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

like image 70
James Black Avatar answered Sep 18 '22 06:09

James Black


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.

like image 29
Brandon Avatar answered Sep 18 '22 06:09

Brandon