Advertisement
Combreal

threading01.cpp

Apr 8th, 2019
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include <iostream>
  2. #include <thread>
  3. #include <string>
  4. #include <windows.h>
  5.  
  6. bool taskPassed = false;
  7.  
  8. static void message()
  9. {
  10.     Sleep(5000);
  11.     std::cout << "\nThanks for waiting\n" << std::endl;
  12.     taskPassed = true;
  13. }
  14.  
  15. int main()
  16. {
  17.     std::thread th(message);
  18.     while (!taskPassed)
  19.     {
  20.         Sleep(500);
  21.         std::cout << ".  ";
  22.     }
  23.     th.join();
  24.     std::cout << "\b\b\b";
  25.     system("pause");
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement