#include<iostream>
#include<thread>
#include<string>
#include<mutex>
using namespace std;
std::mutex mu;
void shared_print(string msg, int i) {
std::lock_guard<std::mutex> guard(mu); //RAII
//mu.lock();
cout << msg << i << endl;
//mu.unlock();
}
void function_1() {
for (int i = 0; i > -100;i--)
shared_print("From t1 : ", i);
}
int main() {
std::thread t1(function_1);
for (int i = 0; i < 100; i++)
shared_print("From main : ", i);
t1.join();
return 0;
}