#include #include #include #include using namespace std ; mutex GMutex ; int shared_data = 0; // Shared resource void increment_shared_data() { for (int i1 = 1; i1 <= 100; ++i1 ) { //TO DO Fix the issue Hint: use mutex GMutex.lock() ; int temp = shared_data ; cout << "Value of shared_data:" << shared_data << " :i1" << i1 << endl ; shared_data = temp + 1 ; GMutex.unlock() ; } } int main() { vector threads; // Create multiple threads that will concurrently modify shared_data for (int i = 0; i < 5; ++i) { threads.push_back( thread(increment_shared_data) ); } // Join all threads to wait for their completion for (thread& t : threads) { t.join(); } cout << "Final value of shared_data: " << shared_data << endl; return 0; }