cpp11/thread.cc

18 lines
510 B
C++

// based on: http://solarianprogrammer.com/2011/12/16/cpp-11-thread-tutorial/
#include <iostream>
#include <thread>
void call_from_thread() {
std::cout << "sleeping in the thread" << std::endl;
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
std::cout << "finishing in thread" << std::endl;
}
int main() {
std::thread t1(call_from_thread);
std::cout << "printing from original thread" << std::endl;
t1.join();
std::cout << "after join" << std::endl;
return 0;
}