如何用时序图来说明多线程?
如何在序列图或类似图中清楚地说明多个执行线程?
我还没有找到任何明确的例子。我看到的所有图表都是用来说明单个线程的。
更新:接受的答案是我看到的最好的例子,但它确实还有一些不足之处。我最终在单独的序列图中说明了线程。我不确定序列图是否一定适用于多个线程。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
这是一个可能有用的图表,在左侧您可以看到解释:
http://sdedit.sourceforge.net/multithreading/example/index.html
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.
这是 sihaya 答案的重复,但详细介绍了如何使用网络上的工具来完成它,以及一个不会消失的视觉示例。
UML 序列图方法是使用“par”片段对并行处理的多个消息进行建模。下面是一个文本描述,当输入到网络上可用的 PlantUML 工具时,将生成下图。
This is a duplicate of sihaya's answer, but with details on how to accomplish it with tools on the web and a visual example that will not disappear.
The UML Sequence diagram approach is to use the "par" fragment to model multiple messages being processed in parallel. Below is a text description which when fed into the PlantUML tool available on the web will produce the diagram below.
您可以使用“par”片段来模拟并行执行的多个同步调用。该片段由一个带有标签“par”的矩形组成。该矩形被分成多个框,每个框代表一个执行线程。
下面是从链接中提取的示例。
本页给出了一个示例:
http://www.ibm.com/developerworks/rational/library/ 3101.html#N10227
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.
Below an example extracted from the link.
An example is given on this page:
http://www.ibm.com/developerworks/rational/library/3101.html#N10227
我喜欢@Brandon的回答。该图显示了清晰的线程通信模型。
我还发现了这份文档,其中有几种不同的方法 https://www .omg.org/ocup-2/documents/concurrency_in_uml_version_2.6.pdf
I like @Brandon's answer. That's a diagram that shows a clear threading communication model.
I also came across this document which has several different approaches https://www.omg.org/ocup-2/documents/concurrency_in_uml_version_2.6.pdf
您可能对消息序列图或MSC感兴趣。
这里是一张简要描述 MSC 的幻灯片。
You may be interested in Message Sequence Charts, or MSC.
Here is a slide describing MSC in a nutshell.