multithreading in c++

#include <iostream>
#include <thread>

void threadFunction() {
    // Code to be executed in the thread
    std::cout << "Hello from the thread!" << std::endl;
}

int main() {
    // Create a thread and pass the function to be executed
    std::thread myThread(threadFunction);

    // Main thread continues its execution

    // Wait for the thread to finish
    myThread.join();

    // Output a message from the main thread
    std::cout << "Hello from the main thread!" << std::endl;

    return 0;
}