天天看点

Ubuntu下使用boost例子

http://blog.csdn.net/dotphoenix/article/details/8459277

1. 安装boost库 

sudo apt-get install libicu-dev

sudo apt-get install libbz2-dev

#include <boost/thread.hpp>  

#include <iostream>  

void task1() {   

    // do stuff  

    std::cout << "this is task1!" << std::endl;  

}  

void task2() {   

    std::cout << "this is task2!" << std::endl;  

int main (int argc, char ** argv) {  

    using namespace boost;   

    thread thread_1 = thread(task1);  

    thread thread_2 = thread(task2);  

    // do other stuff  

    thread_2.join();  

    thread_1.join();  

    return 0;  

}  

继续阅读