#include <iostream>
#include <thread>
static bool s_Finished = false;
void Work()
{
using namespace std::literals::chrono_literals;
std::cout << std::this_thread::get_id() << std::endl;
while (!s_Finished)
{
std::cout << "Working..." << std::endl;
std::this_thread::sleep_for(1s);
}
}
int main()
{
//在用户按下回车前一直打印Working...,按下回车后在执行worker.join();语句之后的程序
std::thread worker(Work);
std::cin.get();
s_Finished = true;
worker.join();
std::cout << "Finish..." << std::endl;
std::cout << std::this_thread::get_id() << std::endl;
std::cin.get();
}