Error while excuting a simple boost thread program
- by Eternal Learner
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 ()())'