Skip to content
Quiz · Multithreading: An Overview · lesson 10 of 12

Quiz — when std::async runs

When and in which thread does answer run in this program?

C++
#include <future>
#include <iostream>

int answer() {
    return 42;
}

int main() {
    std::future<int> f = std::async(std::launch::deferred, answer);
    std::cout << f.get() << '\n';
}

Subscribe to take the course

The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.

Sign in another way