constexpr int TIME_TO_SLEEP1 = 500; constexpr int TIME_TO_SLEEP2 = 1000; auto async_func() { for (auto i = 0; i < 10; ++i) { std::this_thread::sleep_for(std::chrono::milliseconds(TIME_TO_SLEEP1)); std::cout << "非同期処理 c++ async_func" << i << std::endl; } return 0; } int main(int argc, char const *argv[]) { std::cout << "==== start ====" << std::endl; auto work_thread = std::thread([]{ async_func(); }); for (auto i = 0; i < 5; ++i) { std::this_thread::sleep_for(std::chrono::milliseconds(TIME_TO_SLEEP2)); std::cout << "非同期処理 c++ mainFunc" << i << std::endl; } work_thread.join(); return 0; } 13