Skip to content

Latest commit

 

History

History
31 lines (23 loc) · 387 Bytes

Threads.md

File metadata and controls

31 lines (23 loc) · 387 Bytes

Threads in C++

#include <iostream>
#include <thread>
#include <chrono>

static bool = s_Finished = false;

void DoWork()
{
    while (!s_Finished)
    {
        std::cout << "Working...\n";
        std::this_thread::sleep_for(1s);
    }

}

int main()
{
    std::thread worker(DoWork);
    std::cin.get();
    s_Finished = true;

    worker.join();

    std::cin.get();
}