Thread Attributes
The threads produced using the mechanisms described in earlier examples can be sufficient for typical applications. These threads use default scheduling and stack management strategies defined by the Threading package and the underlying thread API. However, other situations might require more control over a thread’s scheduling behavior and stack memory utilization.
For this additional control, the Threading package defines a set of
thread attributes that allow you to choose various thread scheduling and stack management policies. Instances of the
RWThreadAttribute class define the initial attributes for new classes. The
RWThread and
RWThreadSelf classes have methods for manipulating the scheduling attributes of an active thread.
To define the initial attributes for a thread, you create an
RWThreadAttribute instance, set the desired attribute values, and supply this instance to a threaded runnable class instance. The threaded runnable uses the attribute values to configure each new thread created when
start() is called. Once a threaded runnable is started, the scheduling attributes of its active thread can be manipulated using member functions included in the
RWThread and
RWThreadSelf classes.