Skip to content

Instantly share code, notes, and snippets.

@ahupowerdns
Created March 16, 2019 22:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahupowerdns/f208d0dc009b702fe7320f41ccac1c37 to your computer and use it in GitHub Desktop.
Save ahupowerdns/f208d0dc009b702fe7320f41ccac1c37 to your computer and use it in GitHub Desktop.
// g++ syncio.cc -o syncio -std=c++11
#include <iostream>
#include <thread>
#include <string>
#include <unistd.h>
using namespace std;
void theThread()
{
for(int counter = 0 ;; ++counter) {
usleep(250000);
cout << "Hi "<< counter << endl;
}
}
int main()
{
std::ios_base::sync_with_stdio(false);
//cin.tie(nullptr);
string line;
thread t(theThread);
while(getline(cin, line))
;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment