Skip to content

Instantly share code, notes, and snippets.

@why-jay
Created January 24, 2015 06:52
Show Gist options
  • Select an option

  • Save why-jay/0d124d46eba58f812319 to your computer and use it in GitHub Desktop.

Select an option

Save why-jay/0d124d46eba58f812319 to your computer and use it in GitHub Desktop.

Revisions

  1. YJ Yang created this gist Jan 24, 2015.
    24 changes: 24 additions & 0 deletions gistfile1.cpp
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    #include <chrono>
    #include <iostream>
    #include <thread>
    #include <vector>

    using namespace std;

    int main() {
    vector<thread> workers;

    bool isComplete = false;

    thread t = thread([=] {
    int i = 0;
    while (!isComplete) i += 0;
    });

    this_thread::sleep_for(chrono::milliseconds(500));
    isComplete = true;
    t.join();
    cout << "complete!" << endl;

    return 0;
    }