如何在 UML 序列图中对并行线程建模 [英] How to model parallel threads in a UML sequence diagram

查看:73
本文介绍了如何在 UML 序列图中对并行线程建模的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何模拟对序列图中的对象执行操作的两个并行线程?

解决方案

In a

P.S:此示例显示 2 个线程,但您可以通过添加更多水平虚线来添加更多线程.

How can I model two parallel threads that perform operations on an object in a sequence diagram?

解决方案

In a sequence diagram, a lifeline represents an individual participant in the interaction. So your object that is shared between the threads should appear once and only once in the diagram.

You would also represent with a lifeline each threaded object that interact with your shared object. It could be thread instantiations directly, or it could be several objects that are created in the context of the two threads.

But this is not sufficient. In principle, the sequence of the interactions with your object is indicated by the vertical order of the messages. So how to show that interactions may happen in parallel ?

For representing parallelism, you would use a combined fragment introduced by the operator par. Graphically (see link), the combined fragment is represented as a boxed region in your sequence diagram, parallel sequences being separated by horizontal dashed lines (each of the slices would then correspond to one thread of execution.

P.S: this example shows 2 threads, but you can add more threads by adding more horizontal dashed lines.

这篇关于如何在 UML 序列图中对并行线程建模的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆