c++ boost线程列子

#include <boost/thread/thread.hpp>
#include <iostream>

using namespace std;

void hello_world()
{
  cout << "Hello world, I'm a thread!" << endl;
}

int main(int argc, char* argv[])
{
  // 初始化一个线程
  boost::thread my_thread(&hello_world);
  // 等待執行緒完成工做
  my_thread.join();

  return 0;
}

编译:g++ boost_thread.cc -o boost_thread -lboost_thread -lboost_systemios

相关文章
相关标签/搜索