#include <iostream>
#include <string>
#include <thread>
void thread_test(std::string id, unsigned long n) {
for (int i = 0; i < n; i++) {
std::cout << id << " " << i << '\n';
}
}
void demo1() {
std::thread t1{thread_test, "thread1", 10};
//Main thread continues executing here
// ...
// ...
// ...
//Main thread waits here until
t1.join();
}Tips: Split the array in half and have one thread work on each half
//Useful code bits
#include <thread>
//compile with this
g++ mycode.cpp -lpthread
//std::thread t(myfunction, arg1, arg2);
//t.join();