R2016 - modelint/shlaer-mellor-metamodel GitHub Wiki

R2016 / Mc:Mc-1

Instance is executing zero, one or many Method

Method is being executed by zero, one or many Instance


When a class Method is invoked, it is always invoked on some Instance of the Class that defines that Method. A Method may be invoked from within an Activity or as a consequence of a Model Operation. So if a Method is being invoked, it is on a specific Instance.

That said, a Method may be concurrently invoked by each instance of its Class. So the same Method can be invoked by multiple Instances.

But can the same Instance invoke multiple Methods simultaneously?

Yes.

Let's say we have a Class named Vehicle that defines two Methods, say ComputeTimeToCollision and ComputeBrakingDistance.

Imagine that two separate Instances of Classes A and B, let's call these Instances A:I2 and B:I9, are concurrently executing some State Activity or Method of their own. Within one of these Activities is a call to ComputeTimeToCollision being called by A:I2 while B:I9 calls ComputeBrakingDistance. Further, let's assume that both of these calls are on the same Instance, say Vehicle:I1.

So now Instance Vehicle:I1 is concurrently executing both of its Methods.

Summing up, the maximum number of Instances that can executed in a given Method concurrently is the cardinality of the Method's class population. And the maximum number of Methods that can be executed by the same Instance is the number of Methods defined on that Instance's Class.