Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
90
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. #include <chrono>
  4.  
  5. void foo()
  6. {
  7.     std::this_thread::sleep_for(std::chrono::seconds(1));
  8. }
  9.  
  10. int main()
  11. {
  12.     std::thread t1(foo);
  13.     std::thread::id t1_id = t1.get_id();
  14.  
  15.     std::thread t2(foo);
  16.     std::thread::id t2_id = t2.get_id();
  17.  
  18.     std::cout << "t1's id: " << t1_id << '\n';
  19.     std::cout << "t2's id: " << t2_id << '\n';
  20.  
  21.     t1.join();
  22.     t2.join();
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement