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

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


void worker(int id) {
	cout << "thread " << id << " before barrier" << endl;
	this_thread::sleep_for(boost::chrono::milliseconds(id*1000));
	cout << "thread " << id << "waiting at bareier" << 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;
}
