When a barrier is no longer needed, it should be destroyed. Use the pthread_barrier_destroy(3C) function to destroy the barrier referenced by barrier and release any resources used by the barrier.
int pthread_barrier_destroy(pthread_barrier_t *barrier);
#include <pthread.h> pthread_barrier_t barrier; int ret; ret = pthread_barrier_destroy(&barrier);
pthread_barrier_destroy() returns zero after completing successfully. Any other return value indicates that an error occurred. If the following condition occurs, the function fails and returns the corresponding value.
Indicates that the value of barrier was not valid.
An attempt was made to destroy a barrier while it is in use (for example, while being used in a pthread_barrier_wait() by another thread.