added sources and a quote to notes
This commit is contained in:
@@ -1,18 +1,17 @@
|
||||
// based on: http://solarianprogrammer.com/2011/12/16/cpp-11-thread-tutorial/
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
|
||||
//This function will be called from a thread
|
||||
|
||||
void call_from_thread() {
|
||||
std::cout << "Hello, World" << std::endl;
|
||||
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() {
|
||||
//Launch a thread
|
||||
std::thread t1(call_from_thread);
|
||||
|
||||
//Join the thread with the main thread
|
||||
std::cout << "printing from original thread" << std::endl;
|
||||
t1.join();
|
||||
|
||||
std::cout << "after join" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user