本文介绍了主动班与被动班的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在UML规范上层结构2.5中(仍为Beta,第203页)




  • 我想知道是否有一个简单的示例可以说明应用每个方法的区别?

  • 然后对此概念进行详细说明吗?

  • 推荐答案

    按定义,

    被动对象通常不具有
    修改或开始执行流程,因为它们必须
    等待另一个对象调用它们。取而代之的是,被动对象通常是用于存储信息的
    ,并且在许多情况下,该
    信息可以在多个其他对象之间共享。 这可能使
    允许并发访问被动对象,而不是顺序访问。

    为确保其中包含的数据具有较高的完整性,UML
    允许使用被动对象坚持要求他们依次获得
    ;如果两个线程尝试调用相同的顺序
    被动对象,则该对象可以将第二个线程延迟到
    首先完成它。

    Passive objects in UML do not generally have the ability to modify or begin the flow of execution, because they must wait for another object to call them. Instead, passive objects are generally used to store information, and in many cases this information may be shared between multiple other objects. This may allow passive objects to be accessed concurrently, not sequentially. To make sure that the data contained inside has a high integrity, UML allows for passive objects to insist that they be accessed sequentially; if two threads attempt to call the same sequential passive object, that object can delay the second thread until the first has finished with it.

    可以找到一个有用的示例

    A helpful example could be found Here

    这篇关于主动班与被动班的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 00:00