how to free thread object

Hi, I write code to start a thread,but how to free this thread. code: void helloworld() { std::cout << "Hello World!" << std::endl; } int main() { boost::thread thrd(&helloworld); thrd.join(); } -- View this message in context: http://boost.2283326.n4.nabble.com/how-to-free-thread-object-tp3888900p38889... Sent from the Boost - Users mailing list archive at Nabble.com.

AMDG On 10/09/2011 06:20 PM, davieyan wrote:
Hi, I write code to start a thread,but how to free this thread.
What do you mean by freeing the thread? The thread object is destroyed when it goes out of scope, like any other object created on the stack.
code:
void helloworld() { std::cout << "Hello World!" << std::endl; }
int main() { boost::thread thrd(&helloworld); thrd.join(); }
In Christ, Steven Watanabe

davieyan
Hi, I write code to start a thread,but how to free this thread. code:
void helloworld() { std::cout << "Hello World!" << std::endl; }
int main() { boost::thread thrd(&helloworld); thrd.join(); }
-- View this message in context: http://boost.2283326.n4.nabble.com/how-to-free-
thread-object-tp3888900p3888900.html
Sent from the Boost - Users mailing list archive at Nabble.com.
The thread starts in its constructor call with the parameter you passed. At that point, helloworld() executes on the thread. When helloworld() returns, the thread exits. join() waits for it to exit. When main() returns, thrd goes out of scope and is destroyed.
participants (3)
-
Christopher Pisz
-
davieyan
-
Steven Watanabe