What is an Active Object?
An active object is an object that has its own thread of control. That means it can:
- Run independently of other objects.
- Initiate actions, like sending messages or triggering operations.
- Often manage its own behaviour, including timing, coordination, or communication.
This is a key concept when modeling asynchronous or parallel systems, especially in real-time or distributed computing.
Examples of Active Objects
Context | Example | Description |
---|---|---|
UML/Modeling | A Sensor Monitor object |
Periodically polls a sensor and sends alerts. |
Operating Systems | A Process or Thread |
Runs independently and can initiate I/O or computations. |
Embedded Systems | A Controller task |
Continuously monitors and adjusts machinery. |
Actor Model | An Actor |
Processes messages independently and asynchronously. |
Passive Object vs Active Object
Feature | Passive Object | Active Object |
---|---|---|
Control | Does not initiate control | Can initiate control |
Thread of Execution | No | Yes (has its own thread/task) |
Role | Data holder, utility | Behaviour initiator, controller |
Example | Invoice , Customer |
Billing Service , Sensor Monitor |
Active Object Pattern (from Software Design)
There’s even a design pattern called the Active Object Pattern, which is used to decouple method execution from method invocation.
Components of this pattern:
- Proxy: Interface for clients.
- Scheduler: Manages which requests run when.
- Queue: Stores method requests.
- Method Request: Represents a command to execute.
- Servant: The actual object doing the work.
- Thread(s): Execute queued method requests.
Used in systems where you need asynchronous method calls, such as:
- Java’s
Future
andExecutor Service
- C++ with
std::async
or active object libraries
In UML Collaboration or Communication Diagrams
In UML:
- Active objects are often depicted with a thicker border or labeled explicitly.
- They play a key role in scenarios where events, processes, or control flow must be visualized.
Diagram Snippet Example:
[SensorMonitor] --> [AlarmSystem]
(SensorMonitor initiates this)
Here, SensorMonitor
is the active object initiating control.