#include #include #include using namespace std ; mutex gmutex ; void thread_function1( int id ) { for( int i1=1 ; i1<=5 ; i1++ ) { //TO DO Use a unique lock instead gmutex.lock() ; cout << "Thread id: " << id << " i1:" << i1 << endl ; gmutex.unlock() ; } } int main() { //TO DO Create 3 threads that all call "thread_function1" //at the same time. Pass the id's of 1 , 2 and 3 to the //function thread t1( &thread_function1, 1 ) ; thread t2( &thread_function1, 2 ) ; thread t3( &thread_function1, 3 ) ; //Have the 3 threads join in the main t1.join() ; t2.join() ; t3.join() ; cout << "main thread\n" ; return 0; }