Last active
August 29, 2015 13:55
-
-
Save usagi/8773833 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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