Created
January 20, 2014 17:21
-
-
Save usagi/8524485 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 <chrono> | |
| #include <string> | |
| #include <iostream> | |
| int main() | |
| { | |
| std::cerr << "<press enter to exit>\n"; | |
| bool to_continue = true; | |
| auto main_loop_thread = std::thread([&]() | |
| { | |
| size_t n = 0; | |
| while(to_continue) | |
| { | |
| std::this_thread::sleep_for(std::chrono::seconds(1)); | |
| std::cerr << n++ << ' '; | |
| } | |
| }); | |
| std::string buffer; | |
| std::getline(std::cin, buffer); | |
| to_continue = false; | |
| main_loop_thread.join(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment