mercredi 6 mai 2015

Can not declare more than 1.5Million threads in C++

I have run into an issue where I can't declare more than 1.5 million threads. My code compiles fine, but terminates immediately, as soon as I change 1.5 to 1.6 Million. Here is a part of code that is giving me grief.

#include <thread>
#include <mutex>

void run_parallel(arg1, arg2)
{
....
}

int main(int argc, char *argv[]) {

thread t[9000000];
int x =0;
for(int i=0; i< 3000; i++)
    for (int j=0; j<3000; j++)
    {
    t[x] = thread(run_parallel, arg,arg2)
    t[x].join();
    x++;
    }
}

As you can see, I clearly need 9,000,000 threads to run this, but it is not executing. Any help would be mi=uch appreciated.

Aucun commentaire:

Enregistrer un commentaire