Answers for "c++ start thread later"

C++
0

c++ start thread later

#include <iostream>
#include <thread>

void thread_func(const int i) {
    std::cout << "hello from thread: " << i << std::endl;
}

int main() {
    std::thread t;

    t = std::thread{ thread_func, 7 };
    t.join();
}
Posted by: Guest on October-09-2020

Browse Popular Code Answers by Language