Skip to content

Instantly share code, notes, and snippets.

@matrixd
Last active April 18, 2017 22:04
Show Gist options
  • Select an option

  • Save matrixd/7fb05fef38eeabe6c1173ca065679a79 to your computer and use it in GitHub Desktop.

Select an option

Save matrixd/7fb05fef38eeabe6c1173ca065679a79 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <thread>
#include <chrono>
#include <future>
int main()
{
auto future = std::async(std::launch::async, []
{
using namespace std::chrono_literals;
std::this_thread::sleep_for(2s);
std::cout << "sleepy thread... zzZZzz..." << std::endl;
}
);
std::cout << "healthy thread" << std::endl;
using namespace std::chrono_literals;
std::this_thread::sleep_for(7s);
std::cout << "healthy thread has slept for 7s" << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment