CORBA 2.3.3 Programmer's Guide for C++ (NonStop CORBA 2.3.3+)

the condition variable, the current owner of the condition variable must unlock the associated mutex.
Since a mutex is built into a condition variable, you do not need to declare a separate mutex for the condition variable. All you need
to do is to enclose the critical section of code with the lock() and unlock() member functions of the condition variable and use
the wait() and signal() member functions as indicated above.
If needed, you can use the broadcast() method in place of the signal() method. The broadcast() method signals all
threads that are waiting on this condition variable.
Saving and Retrieving Thread-Specific Data
The methods specific_key_create(), specific_set(), and specific_get() allow you to save and retrieve data
specific to a particular thread.
The vthread API provides each thread with a table of thirty-two 32-bit words to store data specific to that thread. Each word can be
used as a pointer to a larger set of data stored elsewhere. This data can then be shared by various application modules associated
with the thread.
To use this feature, do the following within a thread:
Call specific_key_create(). This method returns a key to an entry within the data table for the current thread, and
also allows you to identify the destructor function to be used to clean up data for that key.
To set the value of a 32bit entry in the table, call the specific_set() method, passing the associated key returned by
specific_key_create().
To retrieve the value of a 32bit entry in the table, call the specific_get() method, passing the associated key returned
by specific_key_create().
Terminating Execution of a Thread
In a multithreaded process, you must explicitly exit each thread created by the process. This must be done because an application
process can be designed to run for an extended period of time, and the threads will be present as long as the process is running.
Use Fw_Thread::Exit to terminate the execution of a thread.
Detaching a Thread
Detaching a thread notifies the system that it can reclaim the resources it has allocated to the thread as soon as the thread is
terminated.
Detaching a thread has no immediate effect on a running thread. Your application should call the
Fw_Thread::detach(threadId) function when it determines it does not need to know when a thread completes and has no
interest in any context returned by the thread on exit.
Error Reporting from vthread Methods
The methods in the vthread API return error status in the OSS errno variable. If the result of any method is null, your application
should check errno.
Using a Timer for a Thread
The NonStop CORBA portability and event framework includes a timer mechanism that can be used in multithreaded programs.
This mechanism allows a thread to put itself to sleep for a specified period. At the end of the set period, the thread becomes ready to
run.
This timer mechanism is implemented by the NSDEFw_Timer class, defined in the header file timer.h in the
$NSD_ROOT/include/nsdevent product subdirectory. It uses methods from the thread package (vthread.h) internally.
To create and use a timer for a thread, perform the following steps: