#include <iostream>
#include <string>
#include <thread>

static bool doWokerFlag = true;

void DoWoker()
{
	using namespace std::literals::chrono_literals;

	while (doWokerFlag)
	{
		std::cout << "do working..." << std::endl;
		std::this_thread::sleep_for(1s);
	}
	std::cout << "work done!" << std::endl;
}

int main()
{
	std::thread workder(DoWoker);

	std::cin.get();
	doWokerFlag = false;
	workder.join();

	std::cin.get();
	return 0;
}

  

相关文章:

  • 2022-01-09
  • 2021-06-07
  • 2021-07-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-07
  • 2021-09-10
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-15
  • 2021-07-11
  • 2022-12-23
  • 2021-06-13
相关资源
相似解决方案