// MT3-Q5 #include #include #include #include #include #include using Msgs = std::vector; int main() { Msgs msgs{ "\n msg #1", "\n msg #2", "\n msg #3", "\n msg #4", "\n msg #5" }; std::function writeAsync = [](Msgs inMsgs) { for (auto item : inMsgs) std::cout << item; }; std::thread t(writeAsync, msgs); std::cout << "\n started thread"; t.join(); std::cout << "\n"; std::vector> dones; for (auto item : msgs) { dones.push_back(std::async(std::launch::async, [item]() { std::cout << item; })); } std::cout << "\n started one thread for each item"; for (size_t i=0; i