Advertisement
Gistrec

Simple Thread

Apr 11th, 2018
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <thread>
  2. #include <iostream>
  3. #include <vector>
  4. #include <chrono>
  5.  
  6. void sleepThread(int sec, int number) {
  7.     std::this_thread::sleep_for(std::chrono::milliseconds(sec * 1000));
  8.     std::cout << "Therad " << number << " end work" << std::endl;
  9. }
  10.  
  11. int main() {
  12.     std::thread first(sleepThread, 5, 0);
  13.     std::thread second(sleepThread, 2, 1);
  14.     second.join();
  15.     first.join();
  16.     system("pause");
  17.     return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement