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