Problem with multithreading in Windows
-
Hello,
I've recently installed the Qt 5.3 including the MinGW64 4.9.1. Everything works fine, however I can not use the <future> features. I am running Windows 7 and use NetBeans 7.4 IDE for development. Here is the code I am trying to run:
@
#include <cstdlib>
#include <future>
#include <iostream>using namespace std;
bool is_prime (int x) {
std::cout << "Calculating. Please, wait...\n";
for (int i=2; i<x; ++i) if (x%i==0) return false;
return true;
}int main ()
{
// call is_prime(313222313) asynchronously:
std::future<bool> fut;
fut = std::async(is_prime, 313222313);
std::cout << "Checking whether 313222313 is prime.\n";
// ...bool ret = fut.get(); // waits for is_prime to return
if (ret) std::cout << "It is prime!\n";
else std::cout << "It is not prime.\n";return 0;
}
@I also set the -std=c++11 -pthread flags when compiling the project. When I run it, it just says run failed (exit value -1.073.741.511).
Why could be the problem? Thanks for your help in advance!