Carcigenicate

Better threading

Jan 31st, 2014
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <thread>
  3.  
  4. using namespace std;
  5.  
  6. void count (int in = 1) {
  7.         for (int a = 0, b = 0; a < 99999999; ++a) b = a+a*a+a*a-(a+a*a);
  8.     cout << in << endl;
  9. }
  10.  
  11. void one () {
  12.     for (int a = 0, b = 0; a < 9999999; ++a) b = a+a*a+a*a-(a+a*a); //I know this is probably frowned upon
  13.     cout << "\t\tOne" << endl;
  14. }
  15.  
  16. int main() {
  17.     thread t1;
  18.     thread t2;
  19.    
  20.     for (int a = 0; a < 100; ++a) {
  21.         t1 = thread (count, a);
  22.         t2 = thread (one);
  23.         t1.join (); t2.join ();
  24.     }
  25.    
  26.     cout << "\nDone\n";
  27. }
Advertisement
Add Comment
Please, Sign In to add comment