Skip to content

Instantly share code, notes, and snippets.

@alexkutsan
Created August 3, 2016 18:48
Show Gist options
  • Save alexkutsan/e04d7a7482b95108e288da1b2c973637 to your computer and use it in GitHub Desktop.
Save alexkutsan/e04d7a7482b95108e288da1b2c973637 to your computer and use it in GitHub Desktop.
#include <thread>
#include <iostream>
void foo() {
for(int i = 0; i < 7; ++i) {
std::cout << i << std::endl;
}
}
int main() {
std::thread t;
t.join();
std::cout << "=======" << std::endl;
std::thread(foo).swap(t);
t.join();
std::cout << "=======" << std::endl;
std::thread(foo).swap(t);
t.join();
std::cout << "=======" << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment