Multithreaded Programming Guide

Set Thread Concurrency Level


Unbound threads in a process might or might not be required to be simultaneously active. By default, the threads implementation ensures that a sufficient number of threads are active so that the process can continue to make progress. While this conserves system resources, it might not produce the most effective level of concurrency.

pthread_setconcurrency(3T) allows an application to inform the threads implementation of its desired concurrency level, new_level. The actual level of concurrency provided by the implementation as a result of this function call is unspecified. (For Solaris threads, see "thr_setconcurrency(3T)".)

If new_level is zero, the implementation maintains the concurrency level at its discretion as if pthread_setconcurrency() was never called.

When an application calls pthread_setconcurrency(), it is informing the implementation of its desired concurrency level. The implementation uses this as a hint, not a requirement.

#include <pthread.h>

int pthread_setconcurrency(int new_level);

Return Value

pthread_setconcurrency() fails if:


The value specified by new_level is negative.


The value specified by new_level would cause a system resource to be exceeded.