Guest User

Untitled

a guest
Jan 23rd, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <thread>
  3. #include <vector>
  4. using namespace std;
  5.  
  6. unsigned u = 0;
  7.  
  8. void foo()
  9. {
  10. u++;
  11. }
  12.  
  13. int main()
  14. {
  15. vector<thread> threads;
  16. for(int i = 0; i < 1000; i++) {
  17. threads.push_back (thread (foo));
  18. }
  19. for (auto& t : threads) t.join();
  20.  
  21. cout << u << endl;
  22. return 0;
  23. }
  24.  
  25. if (u % 3 == 0) {
  26. u += 4;
  27. } else {
  28. u -= 1;
  29. }
  30.  
  31. foo():
  32. add DWORD PTR u[rip], 1
  33. ret
  34.  
  35. void foo()
  36. {
  37. unsigned i = u;
  38. for (int s=0;s<10000;s++);
  39. u = i+1;
  40. }
  41.  
  42. if (u % 2) {
  43. u += 2;
  44. } else {
  45. u -= 1;
  46. }
Add Comment
Please, Sign In to add comment