#include #include #include #include #include #include #include #include using namespace std ; int calculate_value() { cout << "Calculating value in background...\n"; this_thread::sleep_for(chrono::seconds(20)); // Simulate long computation return 42; } int main() { future future_result = async(launch::async, calculate_value); cout << "Main thread continues to execute. Waits for 10 seconds\n"; this_thread::sleep_for(chrono::seconds(10)); cout << "Waiting for result...\n"; future_result.wait(); // Blocks until the result is available cout << "function call completed. " << endl; return 0; }