
Hello, I am having problems with running a threads program and was windering if someone could help. I have the following 3 files. 1) example.h class example{ public: example(); virtual ~example(); void operator()(); void someOtherFn(); }; 2) example.cc #include "example.h" C_example::C_example() { } C_example::~C_example() { } void C_example::operator()() { cout << "I'm thread\n"; } 3) main.cc #include <boost/thread/thread.hpp> #include "example.h" int main(int argc, char* argv[]) { example e; boost::thread t1(e); t1.join(); return 0; } I have compiled this and linked with: -lboost_thread-gcc-mt When I run it, I get the following error: terminate called after throwing an instance of 'boost::thread_resource_error' what(): boost::thread_resource_error Abort (core dumped) Any help please?

Hi, On 11/24/07, Rij <rij.ghosh@gmail.com> wrote:
When I run it, I get the following error: terminate called after throwing an instance of 'boost::thread_resource_error' what(): boost::thread_resource_error Abort (core dumped)
IMO, the thread is terminating before your call to 'join'. Considering putting a 'sleep' in the thread function (() operator) or put a 'while true' loop to keep the thread alive. You can use signals/events to notify the thread when it has to exit in a more complete scenario. -dky -- Contents reflect my personal views only!

Rij <rij.ghosh@gmail.com> writes:
I am having problems with running a threads program and was windering if someone could help.
I have compiled this and linked with: -lboost_thread-gcc-mt
You also need to ensure that the correct threading options are enabled (check your gcc docs --- it varies from version to version), and that you are linking against the thread library (-lpthread). Anthony -- Anthony Williams Just Software Solutions Ltd - http://www.justsoftwaresolutions.co.uk Registered in England, Company Number 5478976. Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL
participants (3)
-
Anthony Williams
-
dhruva
-
Rij