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

using namespace boost;
using namespace std;

boost::barrier sync_point(4);

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

int main() {
	boost::thread t1(worker,1);
	boost::thread t2(worker,2);
	boost::thread t3(worker,3);
	boost::thread t4(worker,4);

	t1.join();
	t2.join();
	t3.join();
	t4.join();
	return 0;
	}
