fork(10) download
  1. #include <iostream>
  2. #include <string>
  3. #include <thread>
  4. #include <future>
  5. #include <chrono>
  6.  
  7.  
  8. int main()
  9. {
  10. auto pms = std::promise<std::string>();
  11. auto ftr = pms.get_future();
  12.  
  13. std::thread thread([&](){pms.set_value("hello world");});
  14. ftr.wait();
  15. std::cout << ftr.get() << std::endl;
  16. thread.join ();
  17. return 0;
  18. }
Success #stdin #stdout 0s 6552KB
stdin
Standard input is empty
stdout
hello world