fork(44) download
  1. #include <iostream>
  2. #include <thread>
  3.  
  4. void foo(int a)
  5. {
  6. std::cout << a << '\n';
  7. }
  8.  
  9. int main()
  10. {
  11. // Create and execute the thread
  12. std::thread thread{ foo, 10 }; // Pass 10 to free function
  13.  
  14. // The free function will be executed in a separate thread
  15.  
  16. // Wait for the thread to finish, this is a blocking operation
  17. thread.join();
  18.  
  19. return 0;
  20. }
Success #stdin #stdout 0s 11656KB
stdin
Standard input is empty
stdout
10