quick_exit()不可用

时间:2016-04-24 15:31:39

标签: c++ c++11 gcc mingw-w64

我正在尝试一些线程代码,我使用quick_exit函数来终止程序而不清理资源,下面是我的代码。

#include<future>
#include<iostream>
#include<thread>         // std::thread, std::this_thread::sleep_for
#include<chrono>
#include<cstdlib>

using namespace std;
static void pause_thread(int n)
{
  std::this_thread::sleep_for (std::chrono::seconds(n));
  std::cout << "pause of " << n << " seconds ended\n";
}

int main()
{
  std::cout << "Spawning and detaching 3 threads...\n";
  std::thread (pause_thread,5).detach();
  std::thread (pause_thread,8).detach();
  std::thread (pause_thread,9).detach();
  std::cout << "Done spawning threads.\n";

  std::cout << "(the main thread will now pause for 2 seconds)\n";
  // give the detached threads time to finish (but not guaranteed!):
  pause_thread(2);
  quick_exit(0); //here is the problem,was this a problem?
  return 0;
}

使用GCC 5.3.0编译和我使用的命令

g++ -std=c++11 pracrise.cpp -lpthread

线程模型:posix

我错过了任何内容,我打开了cstdlib的{​​{1}}标题文件。

quick_exit

0 个答案:

没有答案
相关问题