Created
March 10, 2013 04:57
-
-
Save sh19910711/5127191 to your computer and use it in GitHub Desktop.
Boost.AsioでThreadを作る例
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// compile: g++ -lboost_system -lboost_thread thread.cpp | |
#include <iostream> | |
#include <boost/thread.hpp> | |
#include <boost/bind.hpp> | |
void test1() { | |
for ( int i = 0; i < 10; ++ i ) | |
std::cout << "test 1" << std::endl; | |
} | |
void test2() { | |
for ( int i = 0; i < 10; ++ i ) | |
std::cout << "test 2" << std::endl; | |
} | |
int main() { | |
boost::thread t1(test1); | |
boost::thread t2(test2); | |
t1.join(); | |
t2.join(); | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment