c++ put a function in a other thread

#include <iostream>
#include <thread>

void myFunction() {
    // Your function logic goes here
    std::cout << "Function executed in a separate thread." << std::endl;
}

int main() {
    // Create a thread and pass the function to it
    std::thread myThread(myFunction);

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

    return 0;
}