Standards / Extensions | C or C++ | Dependencies |
---|---|---|
POSIX.4a |
both | POSIX(ON) |
#define _OPEN_THREADS
#include <pthread.h>
int pthread_cond_broadcast(pthread_cond_t *cond);
#define _UNIX03_THREADS
#include <pthread.h>
int pthread_cond_broadcast(pthread_cond_t *cond);
Unblock all threads that are blocked on the specified condition variable, cond. If more than one thread is blocked, the order in which the threads are unblocked is unspecified.
pthread_cond_broadcast() has no effect if there are no threads currently blocked on cond.
If successful, pthread_cond_broadcast() returns 0.
Special behavior for Single UNIX Specification, Version 3:
If unsuccessful, pthread_cond_broadcast() returns an error number to indicate the error.
⁄* CELEBP17 *⁄
#define _OPEN_THREADS
#include <pthread.h>
#include <stdio.h>
main() {
pthread_cond_t cond;
if (pthread_cond_init(&cond, NULL) != 0) {
perror("pthread_cond_init() error");
exit(1);
}
if (pthread_cond_broadcast(&cond) != 0) {
perror("pthread_cond_broadcast() error");
exit(2);
}
if (pthread_cond_destroy(&cond) != 0) {
perror("pthread_cond_destroy() error");
exit(3);
}
}