|
Boost Users : |
From: Apostolos Apostolidis (apostolidis.apostolos_at_[hidden])
Date: 2007-10-22 04:51:53
Hi all. I have developed some code allowing a thread group of 500 threads to
run.
However, as soon as the 381st thread is spawned, I get the following runtime
error :
terminate called after throwing an instance of
'boost::thread_resource_error'
what(): boost::thread_resource_error
The Boost documentation does not clarify the nature of the error, so I was
wondering if anyone
can help me out here. The (simple) program code follows.
#include <boost/thread/mutex.hpp>
#include <boost/thread/thread.hpp>
#include <boost/bind.hpp>
using namespace std;
boost::mutex io_mutex;
void foo(int i)
{
boost::mutex::scoped_lock lock(io_mutex);
cout << i << endl;
}
int main(int argc, char *arvg[])
{
boost::thread_group tg;
for(int i = 0;i < 500;i++)
tg.create_thread(boost::bind(&foo,i));
tg.join_all();
}
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