728x90
무슨 말이 필요하랴.. 예제로 보자..
참고로 join 은 thread 시작을 의미하는게 아니고 thread 가 정지할 때까지 기다렸다가 후 처리를 한다는 말이다..
초기화 할 때 이미 thread 는 시작된다
#include <boost/thread.hpp>
void GlobalFunction()
{
while(true)
{
}
}
int _tmain()
{
// default
{
boost::thread t(boost::bind(&GlobalFunction));
t.join();
}
// group
{
boost::thread_group tg;
tg.create_thread(boost::bind(&GlobalFunction));
tg.add_thread(new boost::thread(boost::bind(&GlobalFunction)));
tg.join_all();
}
}
728x90
'프로그래밍 > boost' 카테고리의 다른 글
| boost::asio 비동기 서버/클라 step 1 (0) | 2011.11.09 |
|---|---|
| WorkQueue & Worker (0) | 2011.11.08 |
| ByteStream / CallbackMrg (0) | 2011.11.05 |
| BYTE (unsigned char) Stream 에 boost::pool 적용 (3) | 2011.11.04 |
| boost::function 으로 callback map 만들기 (0) | 2011.11.03 |
댓글