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.
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 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.
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.
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.
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
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'):
Hopefully it helps someone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With