zoukankan      html  css  js  c++  java
  • boost::thread demo

    #include <iostream>
    
    #include <boost/date_time/gregorian/gregorian.hpp>
    #include <boost/date_time/posix_time/posix_time.hpp>
    #include <boost/thread.hpp>
    using namespace boost;
    using namespace boost::posix_time;
    
    void thread_func();
    
    int main(int argc, char** argv)
    {
    	std::cout << "start at main" << std::endl;
    	/*创建线程对象, 完成后马上执行线程函数的代码*/
    	thread t(thread_func);
    	/*调用join,让main函数的线程等待线程t的代码执行完返回再继续*/
    	t.join();
    	std::cout << "the next step will jump out main()" << std::endl;
    	return 0;
    }
    
    
    void thread_func() {
    
    	std::cout << "thread func" << std::endl;
    	/*线程sleep 5秒钟*/
    	boost::this_thread::sleep(boost::posix_time::seconds(5));
    }
    
  • 相关阅读:
    2016.7.17
    2016.7.16
    2016.7.15
    2016.7.12
    2016.7.11
    2016.7.10
    coco2d-x中的坐标系问题
    cocos2d-x中的Tiled地图
    cocos2d-x中的Box2D物理引擎
    python文件处理及装饰器
  • 原文地址:https://www.cnblogs.com/dilex/p/10474367.html
Copyright © 2011-2022 走看看