1 2 3 4 5 6 7 8 9 10 11 12 13
#include <unistd.h> #include <iostream> #include <thread> int main(void) { std::cout << "Before thread" << std::endl; std::thread t([]() { sleep(1); std::cout << "In a thread." << std::endl; }); t.join(); std::cout << "After thread" << std::endl; }