You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
466 B

#include <iostream>
#include <pthread.h>
#include "Mutex.hpp"
Mutex m;
int counter = 0;
void *functionC( void* params )
{
m.lock();
counter++;
std::cout << "Counter value: " << counter << std::endl;
m.unlock();
return 0;
}
int main()
{
pthread_t thread1, thread2;
pthread_create( &thread1, 0, &functionC, 0 );
pthread_create( &thread2, 0, &functionC, 0 );
pthread_join( thread1, 0 );
pthread_join( thread2, 0 );
return 0;
}