Skip to content

Instantly share code, notes, and snippets.

@usagi
Last active August 29, 2015 13:55
Show Gist options
  • Save usagi/8773833 to your computer and use it in GitHub Desktop.
Save usagi/8773833 to your computer and use it in GitHub Desktop.
#include <thread>
#include <string>
#include <chrono>
#include <iostream>
int main()
{
bool is_running = true;
auto t = std::thread([](bool& is_running)
{
std::string buffer;
std::getline(std::cin, buffer);
is_running = false;
}, std::ref(is_running));
while(is_running)
{
std::cerr << "*";
std::this_thread::sleep_for(std::chrono::seconds(1));
}
t.join();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment