Runnable Handle Classes
Many runnable objects supply two different handle classes—one that defines an interface intended for use by outside threads and one that defines an interface that can only be used by the thread running inside the runnable object. Other runnable functions do not have inside or outside access restrictions and are defined in both the internal and external handle classes.
*Outside threads—The RWRunnable and RWThread handles give access to functions that outside threads use to manipulate the corresponding runnable, such as requestInterrupt() or resume().
*Inside threads—The RWRunnableSelf and RWThreadSelf handles give access to functions that can only be used by the thread running inside the runnable, such as serviceInterrupt() or yield().
*Internal and external handle instances—An internal handle instance can be converted to an external handle instance and vice-versa, but any attempt to violate the thread access restrictions imposed by the separate interfaces generally results in an RWTHRIllegalAccess exception.
*Empty handles—A runnable handle instance is not required to reference a body—handles can be constructed in an empty state. Many of the functions provided by the handle class cannot be used if the handle instance is empty. Calls to functions that are normally forwarded to a body instance produce an RWTHRInvalidPointer exception if called on an empty handle. You can test a handle to see if it is empty by using the isValid() member function.
*Body instances—The runnable handle classes do not have any public constructors that build a corresponding body instance. Body instances are constructed by calling one of the static make() functions included in each handle class. These functions dynamically allocate the appropriate body class instance on the heap, and return a temporary handle instance that has been bound to the new body.