Advertisement
Guest User

Untitled

a guest
Jun 8th, 2021
388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include <iostream>
  2. #include <thread>
  3. using namespace std;
  4.  
  5. void test(int i, int j) {
  6.     cout << i+j << endl;
  7. }
  8.  
  9. void test_thread() {
  10.     int num1 = 3;
  11.     int num2 = 4;
  12.     int num3 = 1;
  13.     int num4 = 2;
  14.     thread t1(test, num1, num2);
  15.     thread t2(test, num3, num4);
  16.    
  17.     t1.join();
  18.     t2.join();
  19. }
  20.  
  21. int main()
  22. {
  23.     test_thread();
  24.     cout << "final finish" << endl;
  25.  
  26.     return 0;
  27. }
  28.  
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement