Files

18 lines
510 B
C++
Raw Permalink Normal View History

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