Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Problem with multithreading in Windows
Forum Updated to NodeBB v4.3 + New Features

Problem with multithreading in Windows

Scheduled Pinned Locked Moved C++ Gurus
1 Posts 1 Posters 677 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mcshell
    wrote on 26 Oct 2014, 11:46 last edited by
    #1

    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!

    1 Reply Last reply
    0

    1/1

    26 Oct 2014, 11:46

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved