主动班与被动班 [英] Active class versus passive class

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

问题描述

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


A类可以由将isActive设置为true为活动状态(即
每个实例都是活动对象)。当isActive为false时,
类是被动的(即,它的每个实例都在其他对象的
上下文中执行)。

A Class may be designated by setting isActive to true as active (i.e., each of its instances is an active object). When isActive is false the Class is passive (i.e., each of its instances executes within the context of some other object).




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

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

  • 推荐答案

    按定义,


    活动对象
    在UML中,活动类,以及活动对象
    存在于它们自己的操作线程中,并且有自己的地址
    空间。如果从流的角度考虑执行或代码活动,则
    个活动对象可以启动或控制该流。活动对象(换句话说就是
    )是顺序的并执行某些操作:修改变量,更改
    程序行为等。在UML中,活动类和对象是
    具有比被动对象更粗的边框。

    Active Objects In UML, active classes, and therefore active objects, exist in their own thread of operations and have their own address space. If execution, or code activity, is thought of in terms of flow, active objects can start or control that flow. Active objects, in other words, are sequential and do something: modify variables, change program behavior, and so on. In UML, active classes and objects are distinguished by having a thicker border than passive objects.

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

    为确保其中包含的数据具有较高的完整性,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

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

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