Error while excuting a simple boost thread program

Posted by Eternal Learner on Stack Overflow See other posts from Stack Overflow or by Eternal Learner
Published on 2010-05-15T05:01:53Z Indexed on 2010/05/15 5:14 UTC
Read the original article Hit count: 348

Filed under:
|

Hi All,

Could you tell mw what is the problem with the below boost::thread program

#include<iostream>
#include<boost/thread/thread.hpp>

boost::mutex mutex;

class A
{
public:
A() : a(0) {}

void operator()()
{
          boost::mutex::scoped_lock lock(mutex);

}
private:
int a;

};

int main()
{
    boost::thread thr1(A());
    boost::thread thr2(A());
    thr1.join();
    thr2.join();

}

I get the error message: error: request for member 'join' in 'thr1', which is of non-class type 'boost::thread()(A ()())' BoostThread2.cpp:30: error: request for member 'join' in 'thr2', which is of non-class type 'boost::thread ()(A ()())'

© Stack Overflow or respective owner

Related posts about boost-thread

Related posts about c++