Carcigenicate

Thread Test

Jan 29th, 2014
291
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.  
  4. using namespace std;
  5.  
  6. void count (int in) {
  7.     cout << in << endl;
  8. }
  9.  
  10. void one () {
  11.     for (int a = 0; a < 100000; ++a); //I know this is probably frowned upon
  12.     cout << "One" << endl;
  13. }
  14.  
  15. int main() {
  16.    
  17.     for (int i = 0; i < 1000; ++i) {
  18.     thread countt (count , i); countt.detach ();
  19.     thread onet (one); onet.detach ();
  20.     }
  21.    
  22.     cout << "\nDone\n";
  23. }
Advertisement
Add Comment
Please, Sign In to add comment