#include <iostream>
#include <boost/thread.hpp>
#include <boost/thread/barrier.hpp>

using namespace boost;
using namespace std;
boost:: barrier sync_point(3);

void worker(int id) {
	cout << "Thread: " << id << "before barrier " << endl;
	this_thread::sleep_for(boost::chrono::milliseconds(1000));
	cout << "Thread: " << id << "waiting at barrier " << endl;
	sync_point.wait();
	cout << "Thread: " << id << "passed barrier " << endl;
}

int main() {
	thread t1(worker, 1);
	thread t2(worker, 2);
	thread t3(worker, 3);
	t1.join();
	t2.join();
	t3.join();

	return 0;
}
	
