#include <iostream>
#include <thread>
#include <chrono>
static bool s_finish = false;
g++ -std = c++11 .cpp - o your_program
void Dowork() {
while (!s_finish) {
std::cout << "working" << std::endl;
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
}
}
int main() {
std::thread worker(Dowork);
std::cin.get();
s_finish = true;
worker.join();
return 0;
}
这段代码为啥不能通过编译,说是未包含thread头文件,要命,用的小龙5.16版本的devC++