	/*Racing example*/
#include<iostream>
#include<boost/thread.hpp>
#include<boost/atomic.hpp>
#include<boost/thread/mutex.hpp>


using namespace std;
using namespace boost;


//afou valame to atomic
//gia na apofygo ta mutex pou yparxoun sth standard
int counter=0;
boost::mutex mtx;

void worker()			{

   for (int i=0; i<10000; i++)  { 
        mtx.lock();
	++counter;
        mtx.unlock();
        //to protimo giati den ksero poses operations tha ginoun b4 and rigth after the++
        //alla einai pio argo 
        		}

   				}

int main()
	  {
	  
  thread *t1= new thread(worker);
  thread t2(worker);
  thread *t3= new thread(worker);
  thread *t4= new thread(worker);

    t1->join();
    t2.join();
    t3->join();
    t4->join();
    cout<<"Final counter="<<counter<<endl;
    return 0;

	   }
