15

In UML specification superstructure 2.5(still Beta, page 203)

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).

  • I wonder if there is a simple example illustrates the differences in applying each one of them?
  • And elaborate this concept a bit?
4

1 回答 1

24

By definition,

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.

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

于 2013-01-28T18:19:23.660 回答