Cod sursa(job #2159889)

Utilizator thehellboyhbDarius Ilisie thehellboyhb Data 11 martie 2018 10:58:07
Problema A+B Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.48 kb
#include <ctime>
#include <future>
#include <thread>
#include <iostream>

int long_computation(int x, int y)
{
    std::this_thread::sleep_for(std::chrono::seconds(5));

    return (x + y);
}

int main()
{
    auto f = std::async(std::launch::async, long_computation, 42, 1729);

    // Do things in the meanwhile...
    std::string s;
    std::cin >> s;
    // And we could continue...

    std::cout << f.get(); // Here we join with the asynchronous operation
}