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 08:45:22


> i have been trying to selectively dispose a thread among some other threads
> , but so far i wasnt successful in finding a way to do it .
> suppose i have a simple function which identifies any threads which gets
> into it and if a specific one is located ,it is disposed .
> simply sth like this :
>
> #include <boost/signal.hpp>
> #include <iostream>
> #include <boost/thread.hpp>
> using namespace std;
> boost::thread threadarray[3];
>
> int t(int x)
> {
>     boost::id id();
>     switch(boost::this_thread::get_id())
>     {
>     case threadarray[0].get_id():
>         cout<<"thread 1";
>         break;
>         case threadarray[1].get_id():
>         DISPOSE THIS THREAD or CHANGE OWNERSHITP, OR  GET ANOTHER JOB TO IT
> , OR CHECK IF IT WAS SUCCESSFUL OR NOT

To end the thread, just return from the thread function.


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