Boost logo

Boost Users :

Subject: Re: [Boost-users] How to terminate a specific thread among other threads
From: Igor R (boost.lists_at_[hidden])
Date: 2012-04-15 09:09:36


>> To end the thread, just return from the thread function.
>>
> Ok , how do i know which thread is the one im looking for ? i cant use
> switch statements .!

thread::id class has comparison operators, use "if":
http://www.boost.org/doc/libs/1_49_0/doc/html/thread/thread_management.html#thread.thread_management.thread.id

> and please note that i want to really get rid of the thread, i dont want to
> return each time it is spawned ! ( actaully returning means , get in the
> function , but dont do anything ! right? )

Why is it spawned each time?
Thread is a "thread of execution". When you launch it in c/c++, it
starts in the beginning of some function and ends when the function
ends. So if you return from the thread function, this particular
thread exits.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net