The Runnable Class Hierarchy
The Threading package runnable objects are implemented using a common C++ design technique called the
handle-body idiom. Each runnable instance consists of a protected body instance with one or more public handle instances that reference it. The hierarchy of runnable classes is shown in
Figure 2.
A runnable object is reference-counted. Each runnable body instance keeps a count of the number of handles that currently reference it. A runnable object is deleted when the last handle that references the body is deleted.
The public interface for a runnable is included in its handle classes. Many of the public functions in a handle simply forward control to a corresponding protected function in the body class.
You can find additional information regarding the handle-body idiom and reference-counting in the Smart Pointer package.