Created
March 4, 2016 20:34
-
-
Save danlynn/183eaa73a7fceca499cd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# imagine this code ran in parallel by 2 threads in the same proc | |
@@credit = params[:credit] | |
thread.sleep(1) # lots of work going on here giving other thread chance to set balance from its request | |
account.balance += @@credit # reading value that might have been set by either thread last | |
account.save |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment