The std::async facility allows a function to be executed asynchronously, typically on a new thread (a separate path of execution), and returns a std::future object through which the result can be retrieved later.
The C++ Standard specifies how such operations must behave under both normal and exceptional conditions. One of these requirements concerns thread creation failures.
According to the standard, when std::async is invoked with the std::launch::async launch policy and the implementation is unable to start a new thread, a std::system_error exception must be thrown. The specified error condition is resource_unavailable_try_again. In plain terms, if the system cannot start a new task, the program must report an error that it can handle.
This behavior is important because it provides a predictable mechanism for error handling. Applications can catch the exception, report the failure, initiate recovery actions, or transition to a safe state.