Boost logo

Boost Users :

Subject: Re: [Boost-users] How to terminate a specific thread among other threads
From: Master (master.huricane_at_[hidden])
Date: 2012-04-15 13:03:49


>
> Well, locking the whole thread function you actually prevent the
> threads from running in parallel. You could just lock the shared
> resource, copy it (if it's inexpensive), and release:
> lock_guard<mutex> locker(mutex);
> // copy id objects here to some local array
> locker.unlock();
> // proceed.
>
>
>
> >> int main()
> >> {
> >>
> >> threadarray[0] = boost::thread(t,5);
> >> threadarray[1] = boost::thread(t,6);
> >> threadarray[2] = boost::thread(t,7);
>
> You should lock the above as well, because when you're moving a thread
> object to threadarray, the thread function is already being runnning.
>
> <http://lists.boost.org/mailman/listinfo.cgi/boost-users>
>
i should lock that too? but those threads are somewhere else ! only main
thread is doing the assignment! how would locking help main ? would locking
pause all these threads ?
and what do you mean by :

//* copy id objects here to some local array*

 whats your meaning about id objects ? did you mean the thread id ? , whats
the local array ? an array declared inside that function ? (would be shared
among other threads too right? then whats the point? )
Thank you again for your help sir :)



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