Decoupling a method execution with an active object pattern
The active object design pattern separates and defers method execution from method invocation by running its own control thread.
Motivation
The active object pattern introduces a transparently concurrent model to the application. It creates and starts an internal thread that executes the required logical, critical section. An active object instance exposes a public interface that a client can use to run an encapsulated critical section. An external, client-initiated event is queued and ready to execute. The execution step is performed by the internal scheduler. The result can be passed to the appropriate handler in a callback style.
Sample code
Let us introduce an example of a moving vehicle with a radio system (Example 6.1):
public static void main(String[] args) throws Exception { System.out.println("Active Object Pattern, moving ...