Search code examples
concurrencyuml

What UML diagrams are available for modelling concurrent programs and systems?


What UML diagrams are available for modelling programs and systems that make use of concurrency/parallelism?


Solution

  • Several behavioral UML diagrams and some structural ones may express elements of concurrency. A quick tutorial can be found in OMG's article "Concurrency in UML".

    Here the main tools for modelling concurrency:

    • Activity diagrams are the first diagram that comes to mind, as they are meant to express flows of activity, including cucurrent flows. They provide for example forks and joins, and even allow to highlight visually concurrency using partitions (swim lanes).

      Moreover the semantics of activity diagrams is rooted in petri nets, which was the main tool for modelling concurrent algorithms and distributed systems before UML.

    • sequence diagrams are also a vey usefull diagram for modelling concurrency. First, if active objects are used, their lifelines is a powerful visual tool for showing interaction between concurrent threads. But combined fragments allow to specify elements of concurrency for all kind of objects, in particular with par and critical, but also with seq and strict as these impose constraints on concurrency.

    Other diagrams can help as well, although they are not sufficient on their own to model concurrency:

    • state diagrams can support concurrency with orthogonal states, forks and joins. But is not sufficient, as orthogonal states are also frequent without any concurrency.
    • timing diagrams allow to visualise several lifelines with a specific focus on timing. This is not very usefull for modelling concurrency in behavior, but can be practical to visualise some specific scenarios.
    • class diagram support concurrency with active classes i.e. classes having their instantiation with build-in concurrency.