Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SFML/System.hpp>
- #include <iostream>
- int main()
- {
- int i = 0;
- sf::Thread thread([](int *j) { ++*j; }, &i);
- thread.launch();
- std::cout << i; // This output is a race condition; it's either 0 or 1 depending on how fast the extra thread is executed
- thread.wait();
- std::cout << i;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement