Results 1 to 3 of 3

Thread: boost::thread_resource_error

  1. #1
    Join Date
    Nov 2009
    Beans
    30

    boost::thread_resource_error

    Hello,

    I am encountering the following error:

    **********************************
    terminate called after throwing an instance of 'boost::thread_resource_error'
    what(): boost::thread_resource_error
    Abandon
    **********************************

    trying to run a threadgroup of 500 threads as follows:

    thread_group * thgrp = new thread_group();
    for (int i = 0; i < NUMTHREADS; i++) {
    thgrp->create_thread(bind(&simulate, i, 100, 0.05, 0.2, 1.0, 100, 100, endPrices));
    }
    thgrp->join_all();


    Can anyone please help. I don't understand why I get this error as I have no resource problems with my machine.

    Julien.

  2. #2
    Join Date
    Jun 2007
    Location
    Maryland, US
    Beans
    6,248
    Distro
    Kubuntu

    Re: boost::thread_resource_error

    I thought you might find the information here to be interesting, and related to your question.

    As for your program, you should consider placing the call to boost::thread_group::create_thread() within try/catch blocks.

    Code:
    try {
       for (int i = 0; i < NUMTHREADS; i++) {
          thgrp->create_thread(bind(&simulate, i, 100, 0.05, 0.2, 1.0, 100, 100, endPrices));
       }
    }
    catch (std::exception& e) {
       std::cerr << "Caught exception: " << e.what() << std::endl;
    }
    thgrp->join_all();
    P.S. There's no need to allocate the boost::thread_group object. IIRC, it maintains an STL list of allocated boost::thread objects.

  3. #3
    Join Date
    Nov 2009
    Beans
    30

    Re: boost::thread_resource_error

    thanks a lot for this reply,
    I have too many threads anyway. As suggested by someone, I am going to alter the design of my app.
    Julien.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •