#include <iostream>
#include <mutex>
#include <thread>
#include <unistd.h>

using namespace std;

mutex mtx;

void function(int num) {
    cout << "waiting for the lock in thread " << this_thread::get_id() << endl;
    lock_guard<mutex> lock(mtx);
    sleep(2);
    cout << "Acquired the lock in thread " << this_thread::get_id() << endl;
    return;
}

int main() {
    thread t1(function, 5);
    thread t2(function, 5);

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