Thread Identification
Runnable handles enable you to retrieve an identification value for each thread that is created. This value is needed in many API thread-related functions. You might require the thread “id”:
When you need to directly call the underlying API.
When doing your own thread identification within both your program logic and any debug or status output that you produce.
Thread identification is implemented by the following functions:
RWThreadId rwThreadId() RWThreadId RWRunnableHandle::threadId() The Threading package encapsulates the underlying thread id using the
RWThreadId class. Instances of this class can be used just as if they are instances of the underlying thread id type. That’s because the
RWThreadId class defines constructors and conversion operators that allow it to be used in this manner. For more information about this class, see the
SourcePro API Reference Guide.
NOTE: The
RWThreadId class is in the Synchronization package.
You can get the thread id of the thread executing inside a runnable by calling the runnable’s
RWRunnableHandle::threadId() member. If the runnable does not have an active thread, then
threadId() throws an
RWTHRThreadNotActive exception.
You can use the Synchronization package rwThreadId() function to retrieve the id of the current or calling thread. Any thread can call this function, not just threads created by the library.