Constructing a Thread Pool
To construct a thread pool, you must use one of the static
make() functions provided by the thread pool handle class,
RWThreadPool, as shown in
Example 21.
Example 21 – Constructing a thread pool
// Make a thread pool of 10 threads.
RWThreadPool threadPool=RWThreadPool::make(10);
RWThreadPool’s static make() functions accept parameters detailing the minimum and maximum number of threads in the thread pool and how long a thread will remain in the pool waiting for work before it removes itself. Except for the minimum number of threads in the pool, all of the parameters are optional.
RWThreadPool::make() can also accept
RWThreadAttribute instances that can be used to establish the initial attributes of any threads created by
RWThreadPool. Please note that you are responsible for determining the suitability of thread pool attributes. For example, if you set the start policy of the thread pool attributes to
RW_THR_START_INTERRUPTED, that thread pool would hang because all of the threads in the pool would be waiting for
RWRunnable::releaseInterrupt() calls. See
Thread Attributes for more information.
The work queue is treated as if it has unlimited capacity.