|
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