Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. #include <SFML/System.hpp>
  2. #include <iostream>
  3.  
  4. int main()
  5. {
  6. int i = 0;
  7. sf::Thread thread([](int *j) { ++*j; }, &i);
  8. thread.launch();
  9.  
  10. std::cout << i; // This output is a race condition; it's either 0 or 1 depending on how fast the extra thread is executed
  11.  
  12. thread.wait();
  13.  
  14. std::cout << i;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement