views:

519

answers:

2

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.

+4  A: 

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

James Black
I saw that. Not bad.. but does make me a little dizzy when I read it ;)
Marcus
Handling multiple threads will be a bit daunting, as, part of the reason for using threads is that they are autonomous. You may want to do related threads together, as separate programs. So, Thread 1 (controller thread) starts, spawns 3 threads, they process and report back to controller. Then, these would be in one sequence diagram. There may be 20 other threads being ignored, but that is fine, as they are doing other unrelated tasks.
James Black
A: 

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

Here is a slide describing MSC in a nutshell.

mouviciel
Was there a link with examples of the charts?
Marcus
I edited my answer to link to an example diagram.
mouviciel
I don't see how that represents multiple threads. I must need more caffeine.
Marcus
This is a general formalism for representing activities running in parallel and communicating and synchronizing. This may be processes, threads, realtime tasks or even programs running on different computers.
mouviciel