Using Runnables
Using an active object solves the join problem by creating any necessary threads within the active object’s constructor and joining with them in its destructor. This pattern is similar to the “resource acquisition is initialization” idiom employed by the Synchronization package guard objects (see
Using Guards).
Any of the threaded runnable classes, which are part of the Threading package, can construct an active object. The final choice, though, is dependent on the type of service that the object provides.
Runnables are covered in detail in
The Runnable Object Classes.