如何可视化多线程进程?

发布于 2024-11-26 13:52:59 字数 95 浏览 2 评论 0 原文

我想对多线程应用程序行为进行建模。有很多同步(ManualResetEvents 等)。我尝试使用序列图,但它似乎缺乏方便的同步可视化。那么我必须使用哪种图表来完成此类任务呢?

I want to model multithreading app behavior. There's lot's of synchronization (ManualResetEvents etc.). I tried to use sequence diagram but it seems to lack convenient synchronization visualizations. So what diagram kind I have to use with such kind of tasks?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

时光瘦了 2024-12-03 13:52:59

看看这篇文章

我一直在使用这两种方法UML 活动图和本文中的图

编辑

分享一点经验:不要指望这些图表能够解决多线程的所有设计问题。出于同样的原因,多线程系统的单元测试很困难,绘制图表也很困难。例如,看一下 6.45.Vapuru 的答案中提到的图表。是的,它显示了各层的并发执行,这将帮助您查明潜在的错误,但尝试并可视化在尝试显示网站的多个并发客户端时该图的外观。它很快就会变得混乱。我并不是说它不能完成,但是可能的变化数量如此之大,以至于需要付出很大的努力才能做到正确。

这是一个很好的例子,可以帮助您理解为什么多线程很难。如果你不会画它,你可能没有完全掌握它的复杂性,你将无法测试它,并且你总会有一种忘记了某些东西的感觉。

这就是为什么我希望平台和语言能够解决这些问题,但我们还没有做到这一点。

Have a look at this article

I have been using both the UML activity diagrams and the diagrams in this article

EDIT

To share a bit of experience: do not expect these diagrams to solve all design problems with multithreading. For the same reason that unit testing of multithreaded systems is hard, drawing the diagrams is also though. E.g., have a look at the diagram mentioned in 6.45.Vapuru's answer. Yes, it shows the concurrent execution of the layers and this will help you to pinpoint potential errors but try and visualize what this diagram would look like when attempting to show multiple concurrent clients of the web site. It becomes mess very quickly. I am not saying it can't be done, however the number of possible variations is so huge that it will take a lot of effort to get it right.

This is a nice example to help you understand why multithreading is hard. If you can't draw it, you probably do not grasp its complexity completely, you won't be able to test it and you will always have that nagging feeling you forgot something.

That is why I have my hopes set on platforms and languages to take these issues away but we're not there yet.

剪不断理还乱 2024-12-03 13:52:59

如果您想调查关键对象在有时间约束的情况下相互发送消息时的状态变化,您可以使用 UML 2 时序图

可以检查uml-diagrams.org/timing-diagrams-examples.html" rel="nofollow">http://www.uml-diagrams.org/timing-diagrams-examples.html 站点提供简单的示例时序图 [网站延迟]

If you want to investigate states changes of of the critical objects while they are messaging with each other with timing constraints , you may use UML 2 Timing Diagram

Can check http://www.uml-diagrams.org/timing-diagrams-examples.html site for simple example timing diagram [ Website Latency ]

时光病人 2024-12-03 13:52:59

讨论了以图表方式表示多线程的不同方法图表的最终形式看起来相当不错非常适合使用 ManualResetEvents 可视化同步。

There is a discussion of different approaches to diagrammatically representing multithreading here. The final form of diagram looks quite well suited to visualizing synchronization using ManualResetEvents.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文