Boost logo

Boost Users :

Subject: [Boost-users] [thread] - install - libraries not referencing?
From: Nathan Currier (nathan.currier_at_[hidden])
Date: 2011-12-09 22:19:21


A t.join() before the return in main will wait for the other thread to
finish executing before finishing the program.

On Wednesday, December 7, 2011, Igor R <boost.lists_at_[hidden]> wrote:
>> Thanks. The first extra argument solved the compilation issue, but I now
>> get unexpected output (adding the suggested extra arguments does not help
>> this). In particular, it seems that the second thread is not starting
up,
>> as I only get output from the main thread. The book says I should get a
>> random interleaving of the lines outputted by each thread. My code:
>>
>> void fxn1(){
>> for (int i=0; i<10; ++i){
>> cout << i << ") Do something in parallel with main method." << endl;
>> boost::this_thread::yield();
>> }}
>>
>> int main(){
>> boost::thread t(&fxn1);
>> for (int i=0;i<10; i++){
>> cout << i << ". Do something in main method." << endl;
>> }
>> return 0;
>> }
>
>
> The second thread doens't have a chance to run. Try increasing the
> upper bound of the loops to one million or so.
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users

-- 
- - - - - - - - - - - - - - - - - - - -
*Nathan Currier*


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