Relative Content

Tag Archive for c++multithreadingsynchronizationbarrier

Trying to implement a barrier for pthreads in C++ using pthread condition variables and mutexes

I am currently trying to implement a barrier to control a group of threads. Te barrier class needs a constructor, destructor, and the wait method which I believe I have already created correcty. The thread function is to demonstrate what the class does to the threads by printing which threads are behind the barrier which barrier it was the printing that each thread passed the barrier. When I run the program, it stops printing the statements after the first instance of passing the barrier and only prints the last thread that reached the barrier. Here is the code: