# **[](https://en.cppreference.com/w/cpp/header/future)** provides `std::future` and `std::promise` for passing values or exceptions between threads. `std::async` launches a function on a thread pool (or synchronously, depending on the policy) and returns a future that you wait on for the result. It's the standard way to express "run this on another thread and get the result later." ## Example This example launches an asynchronous task that sleeps and returns a value, then retrieves the result by calling `get()` on the future. ```cpp // compile: g++ -std=c++11 -pthread -o futureexample futureexample.cpp // run: ./futureexample // description: async task with future #include #include #include int slow_computation() { std::this_thread::sleep_for(std::chrono::milliseconds(100)); return 42; } int main() { auto fut = std::async(std::launch::async, slow_computation); std::cout << "waiting for result...\n"; int result = fut.get(); std::cout << "got: " << result << "\n"; return 0; } ```