Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6361557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:47:34+00:00 2026-05-24T23:47:34+00:00

So I try to create simple speed bench with boost 1.47.0. But if I

  • 0

So I try to create simple speed bench with boost 1.47.0. But if I try to create more than 1450 threads it throws exeption. How to get rid of such boost::tread limitation?

My code sample:

#include <iostream>
#include <boost/thread.hpp>
#include <map>
#include <boost/thread.hpp>
#include <boost/thread/locks.hpp>
#include <boost/random/mersenne_twister.hpp>
#include <boost/random/uniform_int_distribution.hpp>
#include <boost/random.hpp>
#include <boost/timer.hpp>

class TestDs 
{
public:

    virtual bool containsKey(int key)=0;
    virtual int get(int key)=0;
    virtual int put(int key, int value)=0;
    virtual int remove(int key)=0;
    virtual int size()=0;
    virtual const char* name()=0;
    virtual void print()=0;
    virtual void shutdown()=0;
};

class GeneralMap: public TestDs
{
private:

    std::map<int,int> _ds;
    mutable boost::mutex mut_;
public:
    GeneralMap() {}

    bool containsKey(int key) {
        boost::mutex::scoped_lock lock(mut_);
        if ( _ds.find(key) != _ds.end())
        {
            return true;
        }
        else
        {
            return false;
        }
    }

    int get(int key) {
        boost::mutex::scoped_lock lock(mut_);
        return _ds[key];
    }

    int put(int key, int value) {
        boost::mutex::scoped_lock lock(mut_);
        _ds.insert(std::pair<int, int>(key,value));
        return key;
    }

    int remove(int key) {
        boost::mutex::scoped_lock lock(mut_);
        return _ds.erase(key);
    }

    int size() {
        boost::mutex::scoped_lock lock(mut_);
        return _ds.size();
    }
    const char* name() {
        return "StdMap";
    }
    void print() {}
    void shutdown() {}

};

int n;
boost::shared_mutex  tests;
boost::shared_mutex  results;
boost::timer timerForCaptureFame;
GeneralMap Ds;

void test( int i)
{
    boost::shared_lock<boost::shared_mutex> lock_r(results);
    boost::shared_lock<boost::shared_mutex> lock(tests);
    Ds.put(i, 0);
    if (Ds.containsKey(i))
    {
        Ds.get(i);
    }
    Ds.remove(i);
}

void result()
{
    boost::upgrade_lock<boost::shared_mutex> lock(results);
    boost::upgrade_to_unique_lock<boost::shared_mutex> uniqueLock(lock);
    std::cout <<  std::endl << "test of " << Ds.name() << " complite;" << std::endl << "test performed on " << n << " items" << std::endl << "test duration: " << timerForCaptureFame.elapsed() << std::endl;
}

void create_tests( int n)
{
    boost::upgrade_lock<boost::shared_mutex> lock(tests);
    boost::upgrade_to_unique_lock<boost::shared_mutex> uniqueLock(lock);
    boost::shared_lock<boost::shared_mutex> lock_r(results);

    for(int i=0; i<n; i++)
    {
        boost::thread worker(test, i);
    }
    boost::thread worker_r(result);
    timerForCaptureFame.restart();
    return;
}

int main()
{
    n = 1000;// if n == 1600 crushes.
    create_tests(n);
    std::cin.get();
    return 0;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T23:47:35+00:00Added an answer on May 24, 2026 at 11:47 pm

    I am not so sure it is a limitation of Boost, but a limitation of Windows. According to Mark Russinovich the maximum threads on a 32 bit OS is 2048 which means you have allocated approximatly 3/4’s of the maximum allowed threads. If you have other processes running it will decrease the amount of threads available for you to use.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I try to create simple speed bench with boost 1.47.0. But results like
I get an error whenever I try to create a simple edge from a
Hy, i'm try to create a simple Telnet Server in python, but the server
I try to create a very simple app using windows API. I've done some
I want to create simple equalizer for android. How can I do it? Try
I try to create simple web service with CXF, Jetty and Spring. I create
I am working a simple form, I spend more than a day to find
i'm a newbie in.net and im try to create a simple site. I have
I try to create a very simple physics engine for my study (processing used
I'm using GAPI to try and create simple reports from our Google Analytics data.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.