#include <iostream>
#include <thread>

using namespace std;


const int num_threads = 10;

void hello_from_thread(int id) {
    // Each thread will do this
    cout << "Hello World from thread " << id << endl;
}


int main() {
    thread t[num_threads]; // Array of threads

    // Launch a group of threads
    for (int i = 0; i < num_threads; ++i) {
        t[i] = thread(hello_from_thread, i);
    }

    cout << "Launched all threads from the main." << endl;

    // Join the threads with the main thread, i.e. wait for them to finish
    for (int i = 0; i < num_threads; ++i) {
        t[i].join();
    }

    return 0;
}
