fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <numeric>
  5. #include <future>
  6. using namespace std;
  7. #include <thread>
  8. int Foo()
  9. {
  10. std::this_thread::sleep_for(5s);
  11. cout << "thread done" << endl;
  12. return 5566;
  13. }
  14.  
  15. int main()
  16. {
  17. std::vector<int> v(10000, 1);
  18. // auto future = std::async(std::launch::async,
  19. // Foo);
  20. std::async(std::launch::async, Foo);
  21. cout << "done" << endl;
  22. }
Success #stdin #stdout 0s 11664KB
stdin
Standard input is empty
stdout
thread done
done