创建文件,复制C++代码,执行下面的命令
g++ -std=c++11 -o async_test -lpthread
#include <future>#include <iostream>#include <string>#include <functional>void func(std::string str){if (pare("Hello World 1") == 0){char pause = getchar(); // 按回车显示}std::cout << str << std::endl;}void Print(std::function< void(std::string)> Functional){auto a = std::async(std::launch::async, Functional, "Hello World 1");auto b = std::async(std::launch::async, Functional, "Hello World 2");auto c = std::async(std::launch::async, Functional, "Hello World 3");}int main(){Print(func);return 0;}